mirror of
https://github.com/curl/curl.git
synced 2026-07-24 20:37:17 +03:00
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).
This commit is contained in:
parent
fa9482ab09
commit
ee56fdb691
21 changed files with 94 additions and 102 deletions
|
|
@ -33,7 +33,7 @@ CURL_EXTERN int curl_strnequal(const char *s1, const char *s2, size_t n);
|
|||
CURL_EXTERN curl_mime *curl_mime_init(CURL *easy);
|
||||
CURL_EXTERN void curl_mime_free(curl_mime *mime);
|
||||
CURL_EXTERN curl_mimepart *curl_mime_addpart(curl_mime *mime);
|
||||
CURL_EXTERN CURLcode curl_mime_name(curl_mimepart *part,
|
||||
CURL_EXTERN CURLcode curl_mime_name(curl_mimepart *part, const char *name);
|
||||
CURL_EXTERN CURLcode curl_mime_filename(curl_mimepart *part,
|
||||
CURL_EXTERN CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype);
|
||||
CURL_EXTERN CURLcode curl_mime_encoder(curl_mimepart *part,
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ int main(int argc, char *argv[])
|
|||
mime1 = curl_mime_init(hnd);
|
||||
part1 = curl_mime_addpart(mime1);
|
||||
curl_mime_data(part1, "value", CURL_ZERO_TERMINATED);
|
||||
curl_mime_name(part1, "name", CURL_ZERO_TERMINATED);
|
||||
curl_mime_name(part1, "name");
|
||||
part1 = curl_mime_addpart(mime1);
|
||||
mime2 = curl_mime_init(hnd);
|
||||
part2 = curl_mime_addpart(mime2);
|
||||
|
|
@ -140,7 +140,7 @@ int main(int argc, char *argv[])
|
|||
slist1 = NULL;
|
||||
curl_mime_subparts(part1, mime2);
|
||||
mime2 = NULL;
|
||||
curl_mime_name(part1, "file", CURL_ZERO_TERMINATED);
|
||||
curl_mime_name(part1, "file");
|
||||
curl_easy_setopt(hnd, CURLOPT_MIMEPOST, mime1);
|
||||
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped");
|
||||
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ static int once(char *URL, bool oldstyle)
|
|||
|
||||
/* Fill in the file upload part */
|
||||
if(oldstyle) {
|
||||
res = curl_mime_name(part, "sendfile", CURL_ZERO_TERMINATED);
|
||||
res = curl_mime_name(part, "sendfile");
|
||||
if(!res)
|
||||
res = curl_mime_data_cb(part, datasize, read_callback,
|
||||
NULL, NULL, &pooh);
|
||||
|
|
@ -122,7 +122,7 @@ static int once(char *URL, bool oldstyle)
|
|||
}
|
||||
else {
|
||||
/* new style */
|
||||
res = curl_mime_name(part, "sendfile alternative", CURL_ZERO_TERMINATED);
|
||||
res = curl_mime_name(part, "sendfile alternative");
|
||||
if(!res)
|
||||
res = curl_mime_data_cb(part, datasize, read_callback,
|
||||
NULL, NULL, &pooh);
|
||||
|
|
@ -151,7 +151,7 @@ static int once(char *URL, bool oldstyle)
|
|||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
/* Fill in the file upload part */
|
||||
res = curl_mime_name(part, "callbackdata", CURL_ZERO_TERMINATED);
|
||||
res = curl_mime_name(part, "callbackdata");
|
||||
if(!res)
|
||||
res = curl_mime_data_cb(part, datasize, read_callback,
|
||||
NULL, NULL, &pooh2);
|
||||
|
|
@ -169,7 +169,7 @@ static int once(char *URL, bool oldstyle)
|
|||
}
|
||||
|
||||
/* Fill in the filename field */
|
||||
res = curl_mime_name(part, "filename", CURL_ZERO_TERMINATED);
|
||||
res = curl_mime_name(part, "filename");
|
||||
if(!res)
|
||||
res = curl_mime_data(part,
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
|
|
@ -193,7 +193,7 @@ static int once(char *URL, bool oldstyle)
|
|||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
res = curl_mime_name(part, "submit", CURL_ZERO_TERMINATED);
|
||||
res = curl_mime_name(part, "submit");
|
||||
if(!res)
|
||||
res = curl_mime_data(part,
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
|
|
@ -216,7 +216,7 @@ static int once(char *URL, bool oldstyle)
|
|||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
res = curl_mime_name(part, "somename", CURL_ZERO_TERMINATED);
|
||||
res = curl_mime_name(part, "somename");
|
||||
if(!res)
|
||||
res = curl_mime_filename(part, "somefile.txt");
|
||||
if(!res)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue