[PATCH 1/3] bootconfig: Support non-ascii characters in value

From
Masami Hiramatsu <mhiramat@kernel.org>
Date
2020-02-14 06:10:23
Also in
lkml
Reply to
Masami Hiramatsu, 2020-02-14
Support non-ascii (u8 code > 128) characters in the
value data. This will allow user to pass utf-8 data
as a value in a bootconfig. (Note that ascii non-
printable characters are still not allowed.)

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 lib/bootconfig.c                              |    2 +-
 tools/bootconfig/samples/good-non-ascii.bconf |    1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 100644 tools/bootconfig/samples/good-non-ascii.bconf
diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index 3ea601a2eba5..9f15b8bef3a0 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -466,7 +466,7 @@ static int __init __xbc_parse_value(char **__v, char **__n)
 	}
 	p = v - 1;
 	while ((c = *++p)) {
-		if (!isprint(c) && !isspace(c))
+		if (c >= 0 && !isprint(c) && !isspace(c))
 			return xbc_parse_error("Non printable value", p);
 		if (quotes) {
 			if (c != quotes)
diff --git a/tools/bootconfig/samples/good-non-ascii.bconf b/tools/bootconfig/samples/good-non-ascii.bconf
new file mode 100644
index 000000000000..b6cb4c24fad6
--- /dev/null
+++ b/tools/bootconfig/samples/good-non-ascii.bconf
@@ -0,0 +1 @@
+hello.japanese = "こんにちは"
Thread (17 messages) 17 messages, 5 authors, last reply 2020-02-18
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help