Skip to content

Commit

Permalink
tools/bootconfig: Fix to use correct quotes for value
Browse files Browse the repository at this point in the history
Fix bootconfig tool to select double or single quotes
correctly according to the value.

If a bootconfig value includes a double quote character,
we must use single-quotes to quote that value.

Link: http://lkml.kernel.org/r/159230245697.65555.12444299015852932304.stgit@devnote2

Cc: stable@vger.kernel.org
Fixes: 950313e ("tools: bootconfig: Add bootconfig command")
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
  • Loading branch information
Masami Hiramatsu authored and Steven Rostedt (VMware) committed Jun 17, 2020
1 parent 4e264ff commit 272da32
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tools/bootconfig/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@
#include <linux/kernel.h>
#include <linux/bootconfig.h>

static int xbc_show_array(struct xbc_node *node)
static int xbc_show_value(struct xbc_node *node)
{
const char *val;
char q;
int i = 0;

xbc_array_for_each_value(node, val) {
printf("\"%s\"%s", val, node->next ? ", " : ";\n");
if (strchr(val, '"'))
q = '\'';
else
q = '"';
printf("%c%s%c%s", q, val, q, node->next ? ", " : ";\n");
i++;
}
return i;
Expand Down Expand Up @@ -48,10 +53,7 @@ static void xbc_show_compact_tree(void)
continue;
} else if (cnode && xbc_node_is_value(cnode)) {
printf("%s = ", xbc_node_get_data(node));
if (cnode->next)
xbc_show_array(cnode);
else
printf("\"%s\";\n", xbc_node_get_data(cnode));
xbc_show_value(cnode);
} else {
printf("%s;\n", xbc_node_get_data(node));
}
Expand Down

0 comments on commit 272da32

Please sign in to comment.