chiark / gitweb /
conf-parser: fix wrong argument given to log_syntax_invalid_utf8
authorRonny Chevalier <chevalier.ronny@gmail.com>
Sun, 14 May 2017 11:19:11 +0000 (13:19 +0200)
committerSven Eden <yamakuzure@gmx.net>
Tue, 25 Jul 2017 07:46:52 +0000 (09:46 +0200)
The condition is on "word", hence we give word instead of rvalue.

An assert would be triggered if !utf8_is_valid(word) is true and
rvalue == NULL, since log_syntax_invalid_utf8 calls utf8_escape_invalid
which calls assert(str).

A test case has been added to test with valid and invalid utf8.

src/shared/conf-parser.c
src/test/test-conf-parser.c

index 06c05a0ce35cdf70d2baf12951792842e894612f..291c4188cab117b8f669de1dcf61772fee977941 100644 (file)
@@ -802,7 +802,7 @@ int config_parse_strv(const char *unit,
                 }
 
                 if (!utf8_is_valid(word)) {
-                        log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, rvalue);
+                        log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, word);
                         free(word);
                         continue;
                 }
index 1d74e1b011c143b5b7ddf51ca5425340defa4858..8e951d7cfeebda3109cf0cf1c6b846268b3b4783 100644 (file)
@@ -190,6 +190,8 @@ static void test_config_parse_strv(void) {
         test_config_parse_strv_one("foo", STRV_MAKE("foo"));
         test_config_parse_strv_one("foo bar foo", STRV_MAKE("foo", "bar", "foo"));
         test_config_parse_strv_one("\"foo bar\" foo", STRV_MAKE("foo bar", "foo"));
+        test_config_parse_strv_one("\xc3\x80", STRV_MAKE("\xc3\x80"));
+        test_config_parse_strv_one("\xc3\x7f", STRV_MAKE_EMPTY);
 }
 
 static void test_config_parse_mode(void) {