Skip to contentSkip to conversation

Fixup quote parsing of kernel arguments

PATCH New Arthur Gautier 1 participant 1 message Apr 2, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fixup quote parsing of kernel arguments

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"'

This commit removes the trailing double quote.

---
 kernel/params.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/params.c +4 -1
index 728e05b..2118546 100644
@@ -156,8 +156,11 @@ static char *next_arg(char *args, char **param, char **val)
 			if (args[i] == '=')
 				equals = i;
 		}
-		if (args[i] == '"')
+		if (args[i] == '"') {
+			if (!equals)
+				args[i] = '\0';
 			in_quote = !in_quote;
+		}
 	}
 
 	*param = args;
Signature · 1 line
2.1.4