]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmdline: fix handling of OperationConfig linked list (--next)
authorRici Lake <ricilake@gmail.com>
Wed, 18 Mar 2020 23:28:19 +0000 (18:28 -0500)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 20 Mar 2020 10:14:12 +0000 (11:14 +0100)
Ensures that -K/--config inserts new items at the end of the list
instead of overwriting the second item, and that after a -K/--config
option has been parsed, the option parser's view of the current config
is update.

Fixes #5120
Closes #5123

src/tool_getparam.c
src/tool_parsecfg.c

index 0c555cc96677706dc632e65da6fa1dc6ef60a166..0252ee0290600a0552a71de3537d9824e6d32aab 100644 (file)
@@ -2258,6 +2258,7 @@ ParameterError parse_args(struct GlobalConfig *global, int argc,
         char *nextarg = (i < (argc - 1)) ? argv[i + 1] : NULL;
 
         result = getparameter(flag, nextarg, &passarg, global, config);
+        config = global->last;
         if(result == PARAM_NEXT_OPERATION) {
           /* Reset result as PARAM_NEXT_OPERATION is only used here and not
              returned from this function */
index a9057ea317f7f810b216c6f6a7da1fdc32a6c022..efb9159e7fb9d6be1bc551f6c7b29da6973b66a3 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -76,7 +76,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
   FILE *file = NULL;
   bool usedarg = FALSE;
   int rc = 0;
-  struct OperationConfig *operation = global->first;
+  struct OperationConfig *operation = global->last;
   char *pathalloc = NULL;
 
   if(!filename || !*filename) {
@@ -233,6 +233,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
       fprintf(stderr, "PARAM: \"%s\"\n",(param ? param : "(null)"));
 #endif
       res = getparameter(option, param, &usedarg, global, operation);
+      operation = global->last;
 
       if(!res && param && *param && !usedarg)
         /* we passed in a parameter that wasn't used! */