diff options
author | Daniel Stenberg <daniel@haxx.se> | 2022-08-30 23:40:19 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2022-08-31 01:03:36 +0200 |
commit | 5b059ba8954c6dcf305ff4def77fe394c7b57401 (patch) | |
tree | d22a9a0042a2049dfd7e688afdf54b4ae3f4fd4d | |
parent | e43c3b3e3e6c2d58084d8c98f8e9640e09c0a05e (diff) | |
download | curl-5b059ba8954c6dcf305ff4def77fe394c7b57401.tar.gz |
getparam: correctly clean args
Follow-up to bf7e887b2442783ab52
The previous fix for #9128 was incomplete and caused #9397.
Fixes #9397
Closes #9399
-rw-r--r-- | src/tool_getparam.c | 15 | ||||
-rw-r--r-- | src/tool_getparam.h | 1 | ||||
-rw-r--r-- | src/tool_parsecfg.c | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/src/tool_getparam.c b/src/tool_getparam.c index f2ad91c19..e6c6a273d 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -558,7 +558,6 @@ static void cleanarg(argv_item_t str) ParameterError getparameter(const char *flag, /* f or -long-flag */ char *nextarg, /* NULL if unset */ - argv_item_t clearthis, bool *usedarg, /* set to TRUE if the arg has been used */ struct GlobalConfig *global, @@ -576,7 +575,9 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ ParameterError err; bool toggle = TRUE; /* how to switch boolean options, on or off. Controlled by using --OPTION or --no-OPTION */ - (void)clearthis; /* for !HAVE_WRITABLE_ARGV builds */ +#ifdef HAVE_WRITABLE_ARGV + argv_item_t clearthis = NULL; +#endif *usedarg = FALSE; /* default is that we don't use the arg */ if(('-' != flag[0]) || ('-' == flag[1])) { @@ -652,6 +653,9 @@ 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) @@ -2443,17 +2447,15 @@ ParameterError parse_args(struct GlobalConfig *global, int argc, stillflags = FALSE; else { char *nextarg = NULL; - argv_item_t clear = NULL; if(i < (argc - 1)) { nextarg = curlx_convert_tchar_to_UTF8(argv[i + 1]); if(!nextarg) { curlx_unicodefree(orig_opt); return PARAM_NO_MEM; } - clear = argv[i + 1]; } - result = getparameter(orig_opt, nextarg, clear, &passarg, + result = getparameter(orig_opt, nextarg, &passarg, global, config); curlx_unicodefree(nextarg); @@ -2492,8 +2494,7 @@ ParameterError parse_args(struct GlobalConfig *global, int argc, bool used; /* Just add the URL please */ - result = getparameter("--url", orig_opt, NULL, &used, global, - config); + result = getparameter("--url", orig_opt, &used, global, config); } if(!result) diff --git a/src/tool_getparam.h b/src/tool_getparam.h index 0564518a6..3eb177391 100644 --- a/src/tool_getparam.h +++ b/src/tool_getparam.h @@ -55,7 +55,6 @@ struct GlobalConfig; struct OperationConfig; ParameterError getparameter(const char *flag, char *nextarg, - argv_item_t clearthis, bool *usedarg, struct GlobalConfig *global, struct OperationConfig *operation); diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c index 34eb5daa9..a166757f8 100644 --- a/src/tool_parsecfg.c +++ b/src/tool_parsecfg.c @@ -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, NULL, &usedarg, global, operation); + res = getparameter(option, param, &usedarg, global, operation); operation = global->last; if(!res && param && *param && !usedarg) |