|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
From 8061fde2d95f0b67d299815a5944abeed0b1ee46 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
From: Ronny Chevalier <chevalier.ronny@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
Date: Sun, 14 May 2017 13:19:11 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
Subject: [PATCH] conf-parser: fix wrong argument given to
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
log_syntax_invalid_utf8
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
The condition is on "word", hence we give word instead of rvalue.
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
An assert would be triggered if !utf8_is_valid(word) is true and
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
rvalue == NULL, since log_syntax_invalid_utf8 calls utf8_escape_invalid
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
which calls assert(str).
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
A test case has been added to test with valid and invalid utf8.
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
(cherry picked from commit b4958f42af08a72cf02e845c8db8d60fe2e5a82f)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
src/shared/conf-parser.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
src/test/test-conf-parser.c | 2 ++
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
2 files changed, 3 insertions(+), 1 deletion(-)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
index 265ac83dc0..863034d18a 100644
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
--- a/src/shared/conf-parser.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+++ b/src/shared/conf-parser.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
@@ -792,7 +792,7 @@ int config_parse_strv(const char *unit,
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
if (!utf8_is_valid(word)) {
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
- log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, rvalue);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, word);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
free(word);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
continue;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
diff --git a/src/test/test-conf-parser.c b/src/test/test-conf-parser.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
index be5d2611f8..26ff27035b 100644
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
--- a/src/test/test-conf-parser.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+++ b/src/test/test-conf-parser.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
@@ -180,6 +180,8 @@ static void test_config_parse_strv(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
test_config_parse_strv_one("foo", STRV_MAKE("foo"));
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
test_config_parse_strv_one("foo bar foo", STRV_MAKE("foo", "bar", "foo"));
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
test_config_parse_strv_one("\"foo bar\" foo", STRV_MAKE("foo bar", "foo"));
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ test_config_parse_strv_one("\xc3\x80", STRV_MAKE("\xc3\x80"));
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ test_config_parse_strv_one("\xc3\x7f", STRV_MAKE_EMPTY);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
static void test_config_parse_mode(void) {
|