← Commit list

8e93a74a73

Daniel Stenberg
Daniel Stenberg
2025-11-06
SUCCESS Duration: 146s

Subject

tool_paramhlp: refuse --proto remove all protocols

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

src/tool_paramhlp.c+10 -6
@@ -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;
}
/**
tests/data/test1474+2 -2
@@ -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>