summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNils Gillmann <ng0@n0.is>2018-09-11 10:16:59 +0000
committerNils Gillmann <ng0@n0.is>2018-09-11 10:16:59 +0000
commit8046e59880e096c1fe5e6a4b70ad57b7cd2d1354 (patch)
treec65cf5624bf702079df31be394de83da98b5b845 /src
parent87430bf69f13500b1feb363ffc099cede490b6e2 (diff)
parent432eb5f5c254ee8383b2522ce597c9219877923e (diff)
downloadgnurl-8046e59880e096c1fe5e6a4b70ad57b7cd2d1354.tar.gz
gnurl-8046e59880e096c1fe5e6a4b70ad57b7cd2d1354.tar.bz2
gnurl-8046e59880e096c1fe5e6a4b70ad57b7cd2d1354.zip
Merge tag 'curl-7_61_1'
curl 7.61.1 Signed-off-by: Nils Gillmann <ng0@n0.is>
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/tool_cb_hdr.c10
-rw-r--r--src/tool_cb_see.c4
-rw-r--r--src/tool_dirhie.c10
-rw-r--r--src/tool_getparam.c60
-rw-r--r--src/tool_metalink.c23
-rw-r--r--src/tool_operate.c56
-rw-r--r--src/tool_urlglob.c6
8 files changed, 114 insertions, 57 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d75f47f17..a289886bd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -62,7 +62,7 @@ include_directories(
)
#Build curl executable
-target_link_libraries( ${EXE_NAME} libcurl ${CURL_LIBS})
+target_link_libraries(${EXE_NAME} libcurl ${CURL_LIBS})
################################################################################
diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c
index 88ce5e13b..04bc7e17b 100644
--- a/src/tool_cb_hdr.c
+++ b/src/tool_cb_hdr.c
@@ -42,7 +42,10 @@ static char *parse_filename(const char *ptr, size_t len);
#define BOLDOFF
#else
#define BOLD "\x1b[1m"
-#define BOLDOFF "\x1b[21m"
+/* Switch off bold by settting "all attributes off" since the explicit
+ bold-off code (21) isn't supported everywhere - like in the mac
+ Terminal. */
+#define BOLDOFF "\x1b[0m"
#endif
/*
@@ -103,9 +106,6 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
(protocol & (CURLPROTO_HTTPS|CURLPROTO_HTTP))) {
const char *p = str + 20;
- if(!outs->stream && !tool_create_output_file(outs, FALSE))
- return failure;
-
/* look for the 'filename=' parameter
(encoded filenames (*=) are not supported) */
for(;;) {
@@ -153,6 +153,8 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
}
break;
}
+ if(!outs->stream && !tool_create_output_file(outs, FALSE))
+ return failure;
}
if(hdrcbdata->config->show_headers &&
diff --git a/src/tool_cb_see.c b/src/tool_cb_see.c
index 621d440f4..061b2bb3d 100644
--- a/src/tool_cb_see.c
+++ b/src/tool_cb_see.c
@@ -118,10 +118,12 @@ int tool_seek_cb(void *userdata, curl_off_t offset, int whence)
int tool_ftruncate64(int fd, curl_off_t where)
{
+ intptr_t handle = _get_osfhandle(fd);
+
if(_lseeki64(fd, where, SEEK_SET) < 0)
return -1;
- if(!SetEndOfFile((HANDLE)_get_osfhandle(fd)))
+ if(!SetEndOfFile((HANDLE)handle))
return -1;
return 0;
diff --git a/src/tool_dirhie.c b/src/tool_dirhie.c
index a01f9dc5f..36c06941c 100644
--- a/src/tool_dirhie.c
+++ b/src/tool_dirhie.c
@@ -139,12 +139,10 @@ CURLcode create_dir_hierarchy(const char *outfile, FILE *errors)
else
snprintf(dirbuildup, outlen, "%s%s", DIR_CHAR, tempdir);
}
- if(access(dirbuildup, F_OK) == -1) {
- if(-1 == mkdir(dirbuildup, (mode_t)0000750)) {
- show_dir_errno(errors, dirbuildup);
- result = CURLE_WRITE_ERROR;
- break; /* get out of loop */
- }
+ if((-1 == mkdir(dirbuildup, (mode_t)0000750)) && (errno != EEXIST)) {
+ show_dir_errno(errors, dirbuildup);
+ result = CURLE_WRITE_ERROR;
+ break; /* get out of loop */
}
}
tempdir = tempdir2;
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index cc3fcf3a5..aad147148 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -65,7 +65,8 @@ struct LongShort {
enum {
ARG_NONE, /* stand-alone but not a boolean */
ARG_BOOL, /* accepts a --no-[name] prefix */
- ARG_STRING /* requires an argument */
+ ARG_STRING, /* requires an argument */
+ ARG_FILENAME /* requires an argument, usually a file name */
} desc;
};
@@ -75,7 +76,7 @@ static const struct LongShort aliases[]= {
{"*@", "url", ARG_STRING},
{"*4", "dns-ipv4-addr", ARG_STRING},
{"*6", "dns-ipv6-addr", ARG_STRING},
- {"*a", "random-file", ARG_STRING},
+ {"*a", "random-file", ARG_FILENAME},
{"*b", "egd-file", ARG_STRING},
{"*B", "oauth2-bearer", ARG_STRING},
{"*c", "connect-timeout", ARG_STRING},
@@ -87,9 +88,9 @@ static const struct LongShort aliases[]= {
/* 'epsv' made like this to make --no-epsv and --epsv to work
although --disable-epsv is the documented option */
{"*F", "dns-servers", ARG_STRING},
- {"*g", "trace", ARG_STRING},
+ {"*g", "trace", ARG_FILENAME},
{"*G", "npn", ARG_BOOL},
- {"*h", "trace-ascii", ARG_STRING},
+ {"*h", "trace-ascii", ARG_FILENAME},
{"*H", "alpn", ARG_BOOL},
{"*i", "limit-rate", ARG_STRING},
{"*j", "compressed", ARG_BOOL},
@@ -108,7 +109,7 @@ static const struct LongShort aliases[]= {
{"*s", "max-redirs", ARG_STRING},
{"*t", "proxy-ntlm", ARG_BOOL},
{"*u", "crlf", ARG_BOOL},
- {"*v", "stderr", ARG_STRING},
+ {"*v", "stderr", ARG_FILENAME},
{"*w", "interface", ARG_STRING},
{"*x", "krb", ARG_STRING},
{"*x", "krb4", ARG_STRING},
@@ -177,7 +178,7 @@ static const struct LongShort aliases[]= {
{"$J", "metalink", ARG_BOOL},
{"$K", "sasl-ir", ARG_BOOL},
{"$L", "test-event", ARG_BOOL},
- {"$M", "unix-socket", ARG_STRING},
+ {"$M", "unix-socket", ARG_FILENAME},
{"$N", "path-as-is", ARG_BOOL},
{"$O", "socks5-gssapi-service", ARG_STRING},
/* 'socks5-gssapi-service' merged with'proxy-service-name' and
@@ -188,7 +189,7 @@ static const struct LongShort aliases[]= {
{"$R", "expect100-timeout", ARG_STRING},
{"$S", "tftp-no-options", ARG_BOOL},
{"$U", "connect-to", ARG_STRING},
- {"$W", "abstract-unix-socket", ARG_STRING},
+ {"$W", "abstract-unix-socket", ARG_FILENAME},
{"$X", "tls-max", ARG_STRING},
{"$Y", "suppress-connect-headers", ARG_BOOL},
{"$Z", "compressed-ssh", ARG_BOOL},
@@ -219,19 +220,19 @@ static const struct LongShort aliases[]= {
{"da", "data-ascii", ARG_STRING},
{"db", "data-binary", ARG_STRING},
{"de", "data-urlencode", ARG_STRING},
- {"D", "dump-header", ARG_STRING},
+ {"D", "dump-header", ARG_FILENAME},
{"e", "referer", ARG_STRING},
- {"E", "cert", ARG_STRING},
- {"Ea", "cacert", ARG_STRING},
+ {"E", "cert", ARG_FILENAME},
+ {"Ea", "cacert", ARG_FILENAME},
{"Eb", "cert-type", ARG_STRING},
- {"Ec", "key", ARG_STRING},
+ {"Ec", "key", ARG_FILENAME},
{"Ed", "key-type", ARG_STRING},
{"Ee", "pass", ARG_STRING},
{"Ef", "engine", ARG_STRING},
- {"Eg", "capath", ARG_STRING},
+ {"Eg", "capath", ARG_FILENAME},
{"Eh", "pubkey", ARG_STRING},
{"Ei", "hostpubmd5", ARG_STRING},
- {"Ej", "crlfile", ARG_STRING},
+ {"Ej", "crlfile", ARG_FILENAME},
{"Ek", "tlsuser", ARG_STRING},
{"El", "tlspassword", ARG_STRING},
{"Em", "tlsauthtype", ARG_STRING},
@@ -246,17 +247,17 @@ static const struct LongShort aliases[]= {
{"Eu", "proxy-tlsuser", ARG_STRING},
{"Ev", "proxy-tlspassword", ARG_STRING},
{"Ew", "proxy-tlsauthtype", ARG_STRING},
- {"Ex", "proxy-cert", ARG_STRING},
+ {"Ex", "proxy-cert", ARG_FILENAME},
{"Ey", "proxy-cert-type", ARG_STRING},
- {"Ez", "proxy-key", ARG_STRING},
+ {"Ez", "proxy-key", ARG_FILENAME},
{"E0", "proxy-key-type", ARG_STRING},
{"E1", "proxy-pass", ARG_STRING},
{"E2", "proxy-ciphers", ARG_STRING},
- {"E3", "proxy-crlfile", ARG_STRING},
+ {"E3", "proxy-crlfile", ARG_FILENAME},
{"E4", "proxy-ssl-allow-beast", ARG_BOOL},
{"E5", "login-options", ARG_STRING},
- {"E6", "proxy-cacert", ARG_STRING},
- {"E7", "proxy-capath", ARG_STRING},
+ {"E6", "proxy-cacert", ARG_FILENAME},
+ {"E7", "proxy-capath", ARG_FILENAME},
{"E8", "proxy-insecure", ARG_BOOL},
{"E9", "proxy-tlsv1", ARG_NONE},
{"EA", "socks5-basic", ARG_BOOL},
@@ -277,7 +278,7 @@ static const struct LongShort aliases[]= {
{"j", "junk-session-cookies", ARG_BOOL},
{"J", "remote-header-name", ARG_BOOL},
{"k", "insecure", ARG_BOOL},
- {"K", "config", ARG_STRING},
+ {"K", "config", ARG_FILENAME},
{"l", "list-only", ARG_BOOL},
{"L", "location", ARG_BOOL},
{"Lt", "location-trusted", ARG_BOOL},
@@ -285,10 +286,10 @@ static const struct LongShort aliases[]= {
{"M", "manual", ARG_BOOL},
{"n", "netrc", ARG_BOOL},
{"no", "netrc-optional", ARG_BOOL},
- {"ne", "netrc-file", ARG_STRING},
+ {"ne", "netrc-file", ARG_FILENAME},
{"N", "buffer", ARG_BOOL},
/* 'buffer' listed as --no-buffer in the help */
- {"o", "output", ARG_STRING},
+ {"o", "output", ARG_FILENAME},
{"O", "remote-name", ARG_NONE},
{"Oa", "remote-name-all", ARG_BOOL},
{"p", "proxytunnel", ARG_BOOL},
@@ -300,7 +301,7 @@ static const struct LongShort aliases[]= {
{"s", "silent", ARG_BOOL},
{"S", "show-error", ARG_BOOL},
{"t", "telnet-option", ARG_STRING},
- {"T", "upload-file", ARG_STRING},
+ {"T", "upload-file", ARG_FILENAME},
{"u", "user", ARG_STRING},
{"U", "proxy-user", ARG_STRING},
{"v", "verbose", ARG_BOOL},
@@ -342,7 +343,7 @@ void parse_cert_parameter(const char *cert_parameter,
* looks like a RFC7512 PKCS#11 URI which can be used as-is.
* Also if cert_parameter contains no colon nor backslash, this
* means no passphrase was given and no characters escaped */
- if(!strncmp(cert_parameter, "pkcs11:", 7) ||
+ if(curl_strnequal(cert_parameter, "pkcs11:", 7) ||
!strpbrk(cert_parameter, ":\\")) {
*certname = strdup(cert_parameter);
return;
@@ -570,7 +571,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
}
}
- if(aliases[hit].desc == ARG_STRING) {
+ if(aliases[hit].desc >= ARG_STRING) {
/* this option requires an extra parameter */
if(!longopt && parse[1]) {
nextarg = (char *)&parse[1]; /* this is the actual extra parameter */
@@ -580,6 +581,13 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
return PARAM_REQUIRES_PARAMETER;
else
*usedarg = TRUE; /* mark it as used */
+
+ if((aliases[hit].desc == ARG_FILENAME) &&
+ (nextarg[0] == '-') && nextarg[1]) {
+ /* if the file name looks like a command line option */
+ warnf(global, "The file name argument '%s' looks like a flag.\n",
+ nextarg);
+ }
}
else if((aliases[hit].desc == ARG_NONE) && !toggle)
return PARAM_NO_PREFIX;
@@ -1706,7 +1714,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
warnf(global, "Failed to open %s!\n", &nextarg[1]);
else {
err = file2memory(&string, &len, file);
- if(!err) {
+ if(!err && string) {
/* Allow strtok() here since this isn't used threaded */
/* !checksrc! disable BANNEDFUNC 2 */
char *h = strtok(string, "\r\n");
@@ -1826,7 +1834,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
config->default_node_flags = toggle?GETOUT_USEREMOTE:0;
break;
}
- /* fall-through! */
+ /* FALLTHROUGH */
case 'o': /* --output */
/* output file */
{
diff --git a/src/tool_metalink.c b/src/tool_metalink.c
index f8effd374..4c4261472 100644
--- a/src/tool_metalink.c
+++ b/src/tool_metalink.c
@@ -461,16 +461,11 @@ static void SHA256_Final(unsigned char digest[32], SHA256_CTX *ctx)
#endif /* CRYPTO LIBS */
-/* Disable this picky gcc-8 compiler warning */
-#if defined(__GNUC__) && (__GNUC__ >= 8)
-#pragma GCC diagnostic ignored "-Wcast-function-type"
-#endif
-
const digest_params MD5_DIGEST_PARAMS[] = {
{
- (Curl_digest_init_func) MD5_Init,
- (Curl_digest_update_func) MD5_Update,
- (Curl_digest_final_func) MD5_Final,
+ CURLX_FUNCTION_CAST(Curl_digest_init_func, MD5_Init),
+ CURLX_FUNCTION_CAST(Curl_digest_update_func, MD5_Update),
+ CURLX_FUNCTION_CAST(Curl_digest_final_func, MD5_Final),
sizeof(MD5_CTX),
16
}
@@ -478,9 +473,9 @@ const digest_params MD5_DIGEST_PARAMS[] = {
const digest_params SHA1_DIGEST_PARAMS[] = {
{
- (Curl_digest_init_func) SHA1_Init,
- (Curl_digest_update_func) SHA1_Update,
- (Curl_digest_final_func) SHA1_Final,
+ CURLX_FUNCTION_CAST(Curl_digest_init_func, SHA1_Init),
+ CURLX_FUNCTION_CAST(Curl_digest_update_func, SHA1_Update),
+ CURLX_FUNCTION_CAST(Curl_digest_final_func, SHA1_Final),
sizeof(SHA_CTX),
20
}
@@ -488,9 +483,9 @@ const digest_params SHA1_DIGEST_PARAMS[] = {
const digest_params SHA256_DIGEST_PARAMS[] = {
{
- (Curl_digest_init_func) SHA256_Init,
- (Curl_digest_update_func) SHA256_Update,
- (Curl_digest_final_func) SHA256_Final,
+ CURLX_FUNCTION_CAST(Curl_digest_init_func, SHA256_Init),
+ CURLX_FUNCTION_CAST(Curl_digest_update_func, SHA256_Update),
+ CURLX_FUNCTION_CAST(Curl_digest_final_func, SHA256_Final),
sizeof(SHA256_CTX),
32
}
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 26fc251f5..2c3f6dd4c 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -113,6 +113,19 @@ static bool is_fatal_error(CURLcode code)
return FALSE;
}
+/*
+ * Check if a given string is a PKCS#11 URI
+ */
+static bool is_pkcs11_uri(const char *string)
+{
+ if(curl_strnequal(string, "pkcs11:", 7)) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+}
+
#ifdef __VMS
/*
* get_vms_file_size does what it takes to get the real size of the file
@@ -1073,6 +1086,46 @@ static CURLcode operate_do(struct GlobalConfig *global,
my_setopt_str(curl, CURLOPT_PINNEDPUBLICKEY, config->pinnedpubkey);
if(curlinfo->features & CURL_VERSION_SSL) {
+ /* Check if config->cert is a PKCS#11 URI and set the
+ * config->cert_type if necessary */
+ if(config->cert) {
+ if(!config->cert_type) {
+ if(is_pkcs11_uri(config->cert)) {
+ config->cert_type = strdup("ENG");
+ }
+ }
+ }
+
+ /* Check if config->key is a PKCS#11 URI and set the
+ * config->key_type if necessary */
+ if(config->key) {
+ if(!config->key_type) {
+ if(is_pkcs11_uri(config->key)) {
+ config->key_type = strdup("ENG");
+ }
+ }
+ }
+
+ /* Check if config->proxy_cert is a PKCS#11 URI and set the
+ * config->proxy_type if necessary */
+ if(config->proxy_cert) {
+ if(!config->proxy_cert_type) {
+ if(is_pkcs11_uri(config->proxy_cert)) {
+ config->proxy_cert_type = strdup("ENG");
+ }
+ }
+ }
+
+ /* Check if config->proxy_key is a PKCS#11 URI and set the
+ * config->proxy_key_type if necessary */
+ if(config->proxy_key) {
+ if(!config->proxy_key_type) {
+ if(is_pkcs11_uri(config->proxy_key)) {
+ config->proxy_key_type = strdup("ENG");
+ }
+ }
+ }
+
my_setopt_str(curl, CURLOPT_SSLCERT, config->cert);
my_setopt_str(curl, CURLOPT_PROXY_SSLCERT, config->proxy_cert);
my_setopt_str(curl, CURLOPT_SSLCERTTYPE, config->cert_type);
@@ -1220,7 +1273,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
my_setopt_str(curl, CURLOPT_TLS13_CIPHERS, config->cipher13_list);
if(config->proxy_cipher13_list)
- my_setopt_str(curl, CURLOPT_PROXY_SSL_CIPHER_LIST,
+ my_setopt_str(curl, CURLOPT_PROXY_TLS13_CIPHERS,
config->proxy_cipher13_list);
/* new in libcurl 7.9.2: */
@@ -1578,6 +1631,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);
switch(response) {
+ case 408: /* Request Timeout */
case 500: /* Internal Server Error */
case 502: /* Bad Gateway */
case 503: /* Service Unavailable */
diff --git a/src/tool_urlglob.c b/src/tool_urlglob.c
index fc8c2f529..e1b994108 100644
--- a/src/tool_urlglob.c
+++ b/src/tool_urlglob.c
@@ -34,8 +34,6 @@
#define GLOBERROR(string, column, code) \
glob->error = string, glob->pos = column, code
-void glob_cleanup(URLGlob* glob);
-
static CURLcode glob_fixed(URLGlob *glob, char *fixed, size_t len)
{
URLPattern *pat = &glob->pattern[glob->size];
@@ -116,7 +114,7 @@ static CURLcode glob_set(URLGlob *glob, char **patternp,
if(multiply(amount, pat->content.Set.size + 1))
return GLOBERROR("range overflow", 0, CURLE_URL_MALFORMAT);
- /* fall-through */
+ /* FALLTHROUGH */
case ',':
*buf = '\0';
@@ -159,7 +157,7 @@ static CURLcode glob_set(URLGlob *glob, char **patternp,
++pattern;
++(*posp);
}
- /* intentional fallthrough */
+ /* FALLTHROUGH */
default:
*buf++ = *pattern++; /* copy character to set element */
++(*posp);