[PATCH 2/4] lib/bootconfig: Fix to remove tailing spaces after value

From: Masami Hiramatsu
Date: Mon Sep 21 2020 - 05:44:58 EST


Fix to remove tailing spaces after value. If there is a space
after value, the bootconfig failed to remove it because it
applies strim() before replacing the delimiter with null.

For example,

foo = var # comment

was parsed as below.

foo="var "

but user will expect

foo="var"

This fixes it by applying strim() after removing the delimiter.

Fixes: 76db5a27a827 ("bootconfig: Add Extra Boot Config support")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
---
0 files changed

diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index b44bba0f1583..649ed44f199c 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -494,8 +494,8 @@ static int __init __xbc_parse_value(char **__v, char **__n)
break;
}
if (strchr(",;\n#}", c)) {
- v = strim(v);
*p++ = '\0';
+ v = strim(v);
break;
}
}