diff options
author | Curl Upstream <curl-library@cool.haxx.se> | 2021-09-14 07:02:52 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-09-15 19:28:31 (GMT) |
commit | 386467c9dc939cd20711c451dd7d60341fd0e802 (patch) | |
tree | 73d1b75e65ec941fff25153f1a10b88dee1e6c2c /lib/formdata.c | |
parent | 18b2a8d7604f3aced9c93220806851f96e231f36 (diff) | |
download | CMake-386467c9dc939cd20711c451dd7d60341fd0e802.zip CMake-386467c9dc939cd20711c451dd7d60341fd0e802.tar.gz CMake-386467c9dc939cd20711c451dd7d60341fd0e802.tar.bz2 |
curl 2021-09-14 (8e82f2a0)
Code extracted from:
https://github.com/curl/curl.git
at commit 8e82f2a04a238c54ba91e553e9a8452e6d405965 (curl-7_79_0).
Diffstat (limited to 'lib/formdata.c')
-rw-r--r-- | lib/formdata.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/formdata.c b/lib/formdata.c index 769f06a..ac7a000 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -865,8 +865,6 @@ CURLcode Curl_getformdata(struct Curl_easy *data, if(post->flags & CURL_HTTPPOST_LARGE) clen = post->contentlen; - if(!clen) - clen = -1; if(post->flags & (HTTPPOST_FILENAME | HTTPPOST_READFILE)) { if(!strcmp(file->contents, "-")) { @@ -888,13 +886,21 @@ CURLcode Curl_getformdata(struct Curl_easy *data, else if(post->flags & HTTPPOST_BUFFER) result = curl_mime_data(part, post->buffer, post->bufferlength? post->bufferlength: -1); - else if(post->flags & HTTPPOST_CALLBACK) + else if(post->flags & HTTPPOST_CALLBACK) { /* the contents should be read with the callback and the size is set with the contentslength */ + if(!clen) + clen = -1; result = curl_mime_data_cb(part, clen, fread_func, NULL, NULL, post->userp); + } else { - result = curl_mime_data(part, post->contents, (ssize_t) clen); + size_t uclen; + if(!clen) + uclen = CURL_ZERO_TERMINATED; + else + uclen = (size_t)clen; + result = curl_mime_data(part, post->contents, uclen); #ifdef CURL_DOES_CONVERSIONS /* Convert textual contents now. */ if(!result && data && part->datasize) |