diff options
author | Patrick Monnerat <patrick@monnerat.net> | 2017-09-03 17:48:15 +0100 |
---|---|---|
committer | Patrick Monnerat <patrick@monnerat.net> | 2017-09-03 17:51:18 +0100 |
commit | 7e36b30da8ef1b69e7932e8a40c7585d8a711d71 (patch) | |
tree | cf405009b18bfe1106ba98bf712ab4d3f2b49174 /src | |
parent | 437475901dddacdac2db7449b1a51ee078b1e48f (diff) |
mime: fix signed/unsigned conversions.
Use and generate CURL_ZERO_TERMINATED in curl tool and tests.
Diffstat (limited to 'src')
-rw-r--r-- | src/tool_setopt.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/tool_setopt.c b/src/tool_setopt.c index 967241d64..b0f319814 100644 --- a/src/tool_setopt.c +++ b/src/tool_setopt.c @@ -487,8 +487,12 @@ static CURLcode libcurl_generate_mime(curl_mime *mime, int *mimeno) Curl_safefree(data); if(!escaped) return CURLE_OUT_OF_MEMORY; - CODE3("curl_mime_data(part%d, \"%s\", %" CURL_FORMAT_CURL_OFF_T ");", - *mimeno, escaped, size); + if(size >= 0) + CODE3("curl_mime_data(part%d, \"%s\", %" CURL_FORMAT_CURL_OFF_T ");", + *mimeno, escaped, size); + else + CODE2("curl_mime_data(part%d, \"%s\", CURL_ZERO_TERMINATED);", + *mimeno, escaped); break; case MIMEKIND_MULTIPART: ret = libcurl_generate_mime(part->arg, &i); @@ -515,12 +519,17 @@ static CURLcode libcurl_generate_mime(curl_mime *mime, int *mimeno) escaped = c_escape(part->name, part->namesize); if(!escaped) return CURLE_OUT_OF_MEMORY; + /* Are there any nul byte in name? */ for(cp = part->name; *cp; cp++) ; - size = (cp == part->name + part->namesize)? - (curl_off_t) -1: (curl_off_t) part->namesize; - CODE3("curl_mime_name(part%d, \"%s\", %" CURL_FORMAT_CURL_OFF_T ");", + 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); } if(part->mimetype) { |