params: handle quotes properly for values not of form foo="bar".
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 15 Apr 2015 03:53:48 +0000 (13:23 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 15 Apr 2015 04:01:23 +0000 (13:31 +0930)
When starting kernel with arguments like:
  init=/bin/sh -c "echo arguments"
the trailing double quote is not removed which results in following command
being executed:
  /bin/sh -c 'echo arguments"'

Reported-by: Arthur Gautier <baloo@gandi.net>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
kernel/params.c

index 728e05b167de984afe2e815f63207952051c3915..a22d6a759b1a9391d5713364097bcfca35f197e7 100644 (file)
@@ -173,9 +173,9 @@ static char *next_arg(char *args, char **param, char **val)
                        if (args[i-1] == '"')
                                args[i-1] = '\0';
                }
-               if (quoted && args[i-1] == '"')
-                       args[i-1] = '\0';
        }
+       if (quoted && args[i-1] == '"')
+               args[i-1] = '\0';
 
        if (args[i]) {
                args[i] = '\0';