tool_getparam: clear argument only when needed

Test 699 verifies

Reported-by: bsr13 on hackerone
Closes #17112
This commit is contained in:
Daniel Stenberg 2025-04-15 17:27:47 +02:00
parent 929c9a7ef7
commit da9494eef0
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 62 additions and 4 deletions

View file

@ -1785,7 +1785,8 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
nextarg = &parse[1]; /* this is the actual extra parameter */
singleopt = TRUE; /* do not loop anymore after this */
#ifdef HAVE_WRITABLE_ARGV
clearthis = &cleararg1[parse + 2 - flag];
if(cleararg1)
clearthis = &cleararg1[parse + 2 - flag];
#endif
}
else if(!nextarg) {
@ -1794,7 +1795,8 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
}
else {
#ifdef HAVE_WRITABLE_ARGV
clearthis = cleararg2;
if(cleararg2)
clearthis = cleararg2;
#endif
*usedarg = TRUE; /* mark it as used */
}