Browse Source

params: handle quotes properly for values not of form foo="bar".

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>
Rusty Russell 10 years ago
parent
commit
b9cc4489c6
1 changed files with 2 additions and 2 deletions
  1. 2 2
      kernel/params.c

+ 2 - 2
kernel/params.c

@@ -173,9 +173,9 @@ static char *next_arg(char *args, char **param, char **val)
 			if (args[i-1] == '"')
 			if (args[i-1] == '"')
 				args[i-1] = '\0';
 				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]) {
 	if (args[i]) {
 		args[i] = '\0';
 		args[i] = '\0';