]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
lib/bootconfig: Fix to remove tailing spaces after value
authorMasami Hiramatsu <mhiramat@kernel.org>
Mon, 21 Sep 2020 09:44:51 +0000 (18:44 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Oct 2020 15:36:33 +0000 (17:36 +0200)
commit c7af4ecdffe1537ba8aeed0ac12c3326f908df43 upstream.

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.

Link: https://lkml.kernel.org/r/160068149134.1088739.8868306567670058853.stgit@devnote2
Fixes: 76db5a27a827 ("bootconfig: Add Extra Boot Config support")
Cc: Ingo Molnar <mingo@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
lib/bootconfig.c

index ad2a9af6fabdaf15e597cf957c490ef6809dbe6e..510a0384861a247e387552a23b1fd2760c7c5958 100644 (file)
@@ -486,8 +486,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;
                }
        }