summaryrefslogtreecommitdiffstats
path: root/Utilities/cmcurl/lib/mime.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-01-31 15:02:45 (GMT)
committerBrad King <brad.king@kitware.com>2024-01-31 15:02:45 (GMT)
commite28ea90c1be2e7d3963effa3f7d80f2c8bf3d1d4 (patch)
tree61d94e6d1e595c9ab06bac9e70a153162f523ab8 /Utilities/cmcurl/lib/mime.c
parent692463d271c5afae5c48b8f05117a9a2e035d6be (diff)
parent851cc904a0f3615c9560a2eeba83e04556c0090b (diff)
downloadCMake-e28ea90c1be2e7d3963effa3f7d80f2c8bf3d1d4.zip
CMake-e28ea90c1be2e7d3963effa3f7d80f2c8bf3d1d4.tar.gz
CMake-e28ea90c1be2e7d3963effa3f7d80f2c8bf3d1d4.tar.bz2
Merge branch 'upstream-curl' into update-curl
* upstream-curl: curl 2024-01-31 (5ce164e0)
Diffstat (limited to 'Utilities/cmcurl/lib/mime.c')
-rw-r--r--Utilities/cmcurl/lib/mime.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/Utilities/cmcurl/lib/mime.c b/Utilities/cmcurl/lib/mime.c
index bb66130..d712331 100644
--- a/Utilities/cmcurl/lib/mime.c
+++ b/Utilities/cmcurl/lib/mime.c
@@ -30,6 +30,7 @@
#include "warnless.h"
#include "urldata.h"
#include "sendf.h"
+#include "strdup.h"
#if !defined(CURL_DISABLE_MIME) && (!defined(CURL_DISABLE_HTTP) || \
!defined(CURL_DISABLE_SMTP) || \
@@ -817,7 +818,7 @@ static size_t read_part_content(curl_mimepart *part,
case MIMEKIND_FILE:
if(part->fp && feof(part->fp))
break; /* At EOF. */
- /* FALLTHROUGH */
+ FALLTHROUGH();
default:
if(part->readfunc) {
if(!(part->flags & MIME_FAST_READ)) {
@@ -936,7 +937,7 @@ static size_t readback_part(curl_mimepart *part,
mimesetstate(&part->state, MIMESTATE_USERHEADERS, hdr->next);
break;
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
case MIMESTATE_CURLHEADERS:
if(!hdr)
mimesetstate(&part->state, MIMESTATE_USERHEADERS, part->userheaders);
@@ -970,7 +971,7 @@ static size_t readback_part(curl_mimepart *part,
fclose(part->fp);
part->fp = NULL;
}
- /* FALLTHROUGH */
+ FALLTHROUGH();
case CURL_READFUNC_ABORT:
case CURL_READFUNC_PAUSE:
case READ_ERROR:
@@ -1235,6 +1236,7 @@ CURLcode Curl_mime_duppart(struct Curl_easy *data,
}
break;
default: /* Invalid kind: should not occur. */
+ DEBUGF(infof(data, "invalid MIMEKIND* attempt"));
res = CURLE_BAD_FUNCTION_ARGUMENT; /* Internal error? */
break;
}
@@ -1370,27 +1372,22 @@ CURLcode curl_mime_filename(curl_mimepart *part, const char *filename)
/* Set mime part content from memory data. */
CURLcode curl_mime_data(curl_mimepart *part,
- const char *data, size_t datasize)
+ const char *ptr, size_t datasize)
{
if(!part)
return CURLE_BAD_FUNCTION_ARGUMENT;
cleanup_part_content(part);
- if(data) {
+ if(ptr) {
if(datasize == CURL_ZERO_TERMINATED)
- datasize = strlen(data);
+ datasize = strlen(ptr);
- part->data = malloc(datasize + 1);
+ part->data = Curl_memdup0(ptr, datasize);
if(!part->data)
return CURLE_OUT_OF_MEMORY;
part->datasize = datasize;
-
- if(datasize)
- memcpy(part->data, data, datasize);
- part->data[datasize] = '\0'; /* Set a null terminator as sentinel. */
-
part->readfunc = mime_mem_read;
part->seekfunc = mime_mem_seek;
part->freefunc = mime_mem_free;