Skip to content

Commit b4958f4

Browse files
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.
1 parent 0839f42 commit b4958f4

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/shared/conf-parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ int config_parse_strv(const char *unit,
793793
}
794794

795795
if (!utf8_is_valid(word)) {
796-
log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, rvalue);
796+
log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, word);
797797
free(word);
798798
continue;
799799
}

src/test/test-conf-parser.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ static void test_config_parse_strv(void) {
180180
test_config_parse_strv_one("foo", STRV_MAKE("foo"));
181181
test_config_parse_strv_one("foo bar foo", STRV_MAKE("foo", "bar", "foo"));
182182
test_config_parse_strv_one("\"foo bar\" foo", STRV_MAKE("foo bar", "foo"));
183+
test_config_parse_strv_one("\xc3\x80", STRV_MAKE("\xc3\x80"));
184+
test_config_parse_strv_one("\xc3\x7f", STRV_MAKE_EMPTY);
183185
}
184186

185187
static void test_config_parse_mode(void) {

0 commit comments

Comments
 (0)