diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-05-31 23:09:59 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-06-22 00:49:58 +0200 |
commit | 8236aba58542c5f89f1d41ca09d84579efb05e22 (patch) | |
tree | 2a4e0b4b5728ae4aa02c39cf9019ae63e0e0b22d /src | |
parent | 26d2755d7c3181e90e46014778941bff53d2309f (diff) | |
download | curl-8236aba58542c5f89f1d41ca09d84579efb05e22.tar.gz |
tool_getparam: -i is not OK if -J is used
Reported-by: sn on hackerone
Bug: https://curl.haxx.se/docs/CVE-2020-8177.html
Diffstat (limited to 'src')
-rw-r--r-- | src/tool_cb_hdr.c | 22 | ||||
-rw-r--r-- | src/tool_getparam.c | 5 |
2 files changed, 9 insertions, 18 deletions
diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c index 3b1023888..b80707fde 100644 --- a/src/tool_cb_hdr.c +++ b/src/tool_cb_hdr.c @@ -186,25 +186,11 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata) filename = parse_filename(p, len); if(filename) { if(outs->stream) { - int rc; - /* already opened and possibly written to */ - if(outs->fopened) - fclose(outs->stream); - outs->stream = NULL; - - /* rename the initial file name to the new file name */ - rc = rename(outs->filename, filename); - if(rc != 0) { - warnf(per->config->global, "Failed to rename %s -> %s: %s\n", - outs->filename, filename, strerror(errno)); - } - if(outs->alloc_filename) - Curl_safefree(outs->filename); - if(rc != 0) { - free(filename); - return failure; - } + /* indication of problem, get out! */ + free(filename); + return failure; } + outs->is_cd_filename = TRUE; outs->s_isreg = TRUE; outs->fopened = FALSE; diff --git a/src/tool_getparam.c b/src/tool_getparam.c index 0cd11c479..1ab3983f4 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -1817,6 +1817,11 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ } break; case 'i': + if(config->content_disposition) { + warnf(global, + "--include and --remote-header-name cannot be combined.\n"); + return PARAM_BAD_USE; + } config->show_headers = toggle; /* show the headers as well in the general output stream */ break; |