From 8e93a74a731714767e2414e1a5687aa0ef31d9ea Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 6 Nov 2025 23:14:04 +0100 Subject: [PATCH] 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 --- src/tool_paramhlp.c | 16 ++++++++++------ tests/data/test1474 | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c index 9f54704ea2..008f0fc388 100644 --- a/src/tool_paramhlp.c +++ b/src/tool_paramhlp.c @@ -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; } /** diff --git a/tests/data/test1474 b/tests/data/test1474 index 8ccecf1877..9ca209cf26 100644 --- a/tests/data/test1474 +++ b/tests/data/test1474 @@ -29,9 +29,9 @@ http # # Verify data after the test has been "shot" -# 1 - Protocol "http" disabled +# 2 failed init, the --proto argument is not accepted -1 +2 -- 2.47.3