tool_paramhlp: refuse --proto remove all protocols

curl is for transfers so disabling all protocols has to be a mistake.
Previously it would allow this to get set (even if curl_easy_setopt()
returns an error for it) and then let libcurl return error instead.

Updated 1474 accordingly.

Closes #19388
This commit is contained in:
Daniel Stenberg 2025-11-06 23:14:04 +01:00
parent e108778db3
commit 8e93a74a73
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 12 additions and 8 deletions

View file

@ -397,7 +397,7 @@ ParameterError proto2num(const char * const *val, char **ostr, const char *str)
const char **protoset;
struct dynbuf obuf;
size_t proto;
CURLcode result;
CURLcode result = CURLE_OK;
curlx_dyn_init(&obuf, MAX_PROTOSTRING);
@ -496,15 +496,19 @@ ParameterError proto2num(const char * const *val, char **ostr, const char *str)
qsort((char *) protoset, protoset_index(protoset, NULL), sizeof(*protoset),
struplocompare4sort);
result = curlx_dyn_addn(&obuf, "", 0);
for(proto = 0; protoset[proto] && !result; proto++)
result = curlx_dyn_addf(&obuf, "%s,", protoset[proto]);
result = curlx_dyn_addf(&obuf, "%s%s", curlx_dyn_len(&obuf) ? "," : "",
protoset[proto]);
free((char *) protoset);
curlx_dyn_setlen(&obuf, curlx_dyn_len(&obuf) - 1);
if(result)
return PARAM_NO_MEM;
if(!curlx_dyn_len(&obuf)) {
curlx_dyn_free(&obuf);
return PARAM_BAD_USE;
}
free(*ostr);
*ostr = curlx_dyn_ptr(&obuf);
return *ostr ? PARAM_OK : PARAM_NO_MEM;
return PARAM_OK;
}
/**

View file

@ -29,9 +29,9 @@ http
#
# Verify data after the test has been "shot"
<verify>
# 1 - Protocol "http" disabled
# 2 failed init, the --proto argument is not accepted
<errorcode>
1
2
</errorcode>
</verify>
</testcase>