conf-parser: fix wrong argument given to log_syntax_invalid_utf8

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.
This commit is contained in:
Ronny Chevalier
2017-05-14 13:19:11 +02:00
parent 0839f42ebf
commit b4958f42af
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -793,7 +793,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;
}
+2
View File
@@ -180,6 +180,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) {