tool_getparam: fix hiding of command line secrets

Closes #10276
This commit is contained in:
Harry Sintonen 2023-01-11 11:39:33 +01:00 committed by Daniel Stenberg
parent d6b5d9f4ae
commit 2ed0e1f70e
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
3 changed files with 10 additions and 7 deletions

View File

@ -660,6 +660,7 @@ static ParameterError data_urlencode(struct GlobalConfig *global,
ParameterError getparameter(const char *flag, /* f or -long-flag */
char *nextarg, /* NULL if unset */
argv_item_t cleararg,
bool *usedarg, /* set to TRUE if the arg
has been used */
struct GlobalConfig *global,
@ -764,15 +765,16 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
/* this option requires an extra parameter */
if(!longopt && parse[1]) {
nextarg = (char *)&parse[1]; /* this is the actual extra parameter */
#ifdef HAVE_WRITABLE_ARGV
clearthis = nextarg;
#endif
singleopt = TRUE; /* don't loop anymore after this */
}
else if(!nextarg)
return PARAM_REQUIRES_PARAMETER;
else
else {
#ifdef HAVE_WRITABLE_ARGV
clearthis = cleararg;
#endif
*usedarg = TRUE; /* mark it as used */
}
if((aliases[hit].desc == ARG_FILENAME) &&
(nextarg[0] == '-') && nextarg[1]) {
@ -2494,7 +2496,7 @@ ParameterError parse_args(struct GlobalConfig *global, int argc,
}
}
result = getparameter(orig_opt, nextarg, &passarg,
result = getparameter(orig_opt, nextarg, argv[i + 1], &passarg,
global, config);
curlx_unicodefree(nextarg);
@ -2533,7 +2535,7 @@ ParameterError parse_args(struct GlobalConfig *global, int argc,
bool used;
/* Just add the URL please */
result = getparameter("--url", orig_opt, &used, global, config);
result = getparameter("--url", orig_opt, argv[i], &used, global, config);
}
if(!result)

View File

@ -55,6 +55,7 @@ struct GlobalConfig;
struct OperationConfig;
ParameterError getparameter(const char *flag, char *nextarg,
argv_item_t cleararg,
bool *usedarg,
struct GlobalConfig *global,
struct OperationConfig *operation);

View File

@ -223,7 +223,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
#ifdef DEBUG_CONFIG
fprintf(stderr, "PARAM: \"%s\"\n",(param ? param : "(null)"));
#endif
res = getparameter(option, param, &usedarg, global, operation);
res = getparameter(option, param, NULL, &usedarg, global, operation);
operation = global->last;
if(!res && param && *param && !usedarg)