summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatrick Monnerat <patrick@monnerat.net>2017-09-22 01:08:29 +0100
committerPatrick Monnerat <patrick@monnerat.net>2017-09-22 01:08:29 +0100
commitee56fdb6910f6bf215eecede9e2e9bfc83cb5f29 (patch)
treebfdbf1f3f2f5cd9f051f6b8d0b2469c51b2660ef /src
parentfa9482ab0907dfacd0fb619add2dbf41de2d8c9c (diff)
downloadcurl-ee56fdb6910f6bf215eecede9e2e9bfc83cb5f29.tar.gz
form/mime: field names are not allowed to contain zero-valued bytes.
Also suppress length argument of curl_mime_name() (names are always zero-terminated).
Diffstat (limited to 'src')
-rw-r--r--src/tool_formparse.c2
-rw-r--r--src/tool_setopt.c14
2 files changed, 3 insertions, 13 deletions
diff --git a/src/tool_formparse.c b/src/tool_formparse.c
index 21cb2820b..4645a761e 100644
--- a/src/tool_formparse.c
+++ b/src/tool_formparse.c
@@ -733,7 +733,7 @@ int formparse(struct OperationConfig *config,
}
/* Set part name. */
- if(name && curl_mime_name(part, name, CURL_ZERO_TERMINATED)) {
+ if(name && curl_mime_name(part, name)) {
warnf(config->global, "curl_mime_name failed!\n");
Curl_safefree(contents);
return 31;
diff --git a/src/tool_setopt.c b/src/tool_setopt.c
index fd9bba4d6..fb2cb66d3 100644
--- a/src/tool_setopt.c
+++ b/src/tool_setopt.c
@@ -525,20 +525,10 @@ static CURLcode libcurl_generate_mime(curl_mime *mime, int *mimeno)
if(part->name) {
Curl_safefree(escaped);
- escaped = c_escape(part->name, part->namesize);
+ escaped = c_escape(part->name, CURL_ZERO_TERMINATED);
if(!escaped)
return CURLE_OUT_OF_MEMORY;
- /* Are there any nul byte in name? */
- for(cp = part->name; *cp; cp++)
- ;
- if(cp != part->name + part->namesize) {
- size = (curl_off_t) part->namesize;
- CODE3("curl_mime_name(part%d, \"%s\", %" CURL_FORMAT_CURL_OFF_T ");",
- *mimeno, escaped, size);
- }
- else
- CODE2("curl_mime_name(part%d, \"%s\", CURL_ZERO_TERMINATED);",
- *mimeno, escaped);
+ CODE2("curl_mime_name(part%d, \"%s\");", *mimeno, escaped);
}
if(part->mimetype) {