From 19248dcec53d19184ce1207962edd54109d28b01 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 25 Oct 2023 07:17:36 +1300 Subject: bootstd: Handle a few special cases in cmdline_set_arg() Two bugs have appeared: - arguments can have an equals sign embedded in them, which must be considered part of the value - arguments must fully match the name; partial matches should be ignored Fix these and add a test to cover both. Signed-off-by: Simon Glass --- boot/bootflow.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'boot/bootflow.c') diff --git a/boot/bootflow.c b/boot/bootflow.c index be543c8588c..6922e7e0c4e 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -752,7 +752,7 @@ int cmdline_set_arg(char *buf, int maxlen, const char *cmdline, in_quote = false; continue; } - if (*p == '=') { + if (*p == '=' && !arg_end) { arg_end = p; val = p + 1; } else if (*p == '"') { @@ -788,7 +788,8 @@ int cmdline_set_arg(char *buf, int maxlen, const char *cmdline, } /* if this is the target arg, update it */ - if (!strncmp(from, set_arg, arg_end - from)) { + if (arg_end - from == set_arg_len && + !strncmp(from, set_arg, set_arg_len)) { if (!buf) { bool has_quote = val_end[-1] == '"'; -- cgit v1.2.3