mirror of
https://github.com/curl/curl.git
synced 2025-09-10 22:22:43 +03:00
tool_formparse: remove use of sscanf()
In the function for handling 'type=' in the -F command line arguments, we make the code more lax to accept more strings and thereby also avoid the use of sscanf(). Closes #15683
This commit is contained in:
parent
03669b630e
commit
9664d5a547
|
@ -469,8 +469,6 @@ static int get_param_part(struct OperationConfig *config, char endchar,
|
||||||
char *endpos;
|
char *endpos;
|
||||||
char *tp;
|
char *tp;
|
||||||
char sep;
|
char sep;
|
||||||
char type_major[128] = "";
|
|
||||||
char type_minor[128] = "";
|
|
||||||
char *endct = NULL;
|
char *endct = NULL;
|
||||||
struct curl_slist *headers = NULL;
|
struct curl_slist *headers = NULL;
|
||||||
|
|
||||||
|
@ -502,18 +500,10 @@ static int get_param_part(struct OperationConfig *config, char endchar,
|
||||||
/* set type pointer */
|
/* set type pointer */
|
||||||
type = p;
|
type = p;
|
||||||
|
|
||||||
/* verify that this is a fine type specifier */
|
/* find end of content-type */
|
||||||
if(2 != sscanf(type, "%127[^/ ]/%127[^;, \n]", type_major, type_minor)) {
|
while(*p && (ISALPHA(*p) || (*p == '/') || (*p == '-')))
|
||||||
warnf(config->global, "Illegally formatted content-type field");
|
p++;
|
||||||
curl_slist_free_all(headers);
|
endct = p;
|
||||||
return -1; /* illegal content-type syntax! */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now point beyond the content-type specifier */
|
|
||||||
p = type + strlen(type_major) + strlen(type_minor) + 1;
|
|
||||||
for(endct = p; *p && *p != ';' && *p != endchar; p++)
|
|
||||||
if(!ISSPACE(*p))
|
|
||||||
endct = p + 1;
|
|
||||||
sep = *p;
|
sep = *p;
|
||||||
}
|
}
|
||||||
else if(checkprefix("filename=", p)) {
|
else if(checkprefix("filename=", p)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user