summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-06-03 23:57:30 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-06-03 23:57:30 +0900
commitcd4f53c5b5925312170114bd2649a60d1f541c12 (patch)
treec2d90bc975bd981aaa4ffa8aa0487feca7492d7e
parent58a53adde559fced6c7ce909d03c61a21ccd73eb (diff)
downloadsystemd-cd4f53c5b5925312170114bd2649a60d1f541c12.tar.gz
conf-parse: use path_simplify_and_warn() in config_parse_path()
-rw-r--r--src/shared/conf-parser.c20
-rw-r--r--src/test/test-conf-parser.c1
2 files changed, 6 insertions, 15 deletions
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index f10366c265..a71ff524ae 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -713,6 +713,7 @@ int config_parse_path(
char **s = data, *n;
bool fatal = ltype;
+ int r;
assert(filename);
assert(lvalue);
@@ -724,27 +725,16 @@ int config_parse_path(
goto finalize;
}
- if (!utf8_is_valid(rvalue)) {
- log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, rvalue);
- return fatal ? -ENOEXEC : 0;
- }
-
- if (!path_is_absolute(rvalue)) {
- log_syntax(unit, LOG_ERR, filename, line, 0,
- "Not an absolute path%s: %s",
- fatal ? "" : ", ignoring", rvalue);
- return fatal ? -ENOEXEC : 0;
- }
-
n = strdup(rvalue);
if (!n)
return log_oom();
- path_simplify(n, false);
+ r = path_simplify_and_warn(n, PATH_CHECK_ABSOLUTE | (fatal ? PATH_CHECK_FATAL : 0), unit, filename, line, lvalue);
+ if (r < 0)
+ return fatal ? -ENOEXEC : 0;
finalize:
- free(*s);
- *s = n;
+ free_and_replace(*s, n);
return 0;
}
diff --git a/src/test/test-conf-parser.c b/src/test/test-conf-parser.c
index d569bdd85f..f0e3d6c07e 100644
--- a/src/test/test-conf-parser.c
+++ b/src/test/test-conf-parser.c
@@ -96,6 +96,7 @@ static void test_config_parse_path(void) {
test_config_parse_path_one("/path", "/path");
test_config_parse_path_one("/path//////////", "/path");
test_config_parse_path_one("///path/foo///bar////bar//", "/path/foo/bar/bar");
+ test_config_parse_path_one("/path//./////hogehoge///.", "/path/hogehoge");
test_config_parse_path_one("/path/\xc3\x80", "/path/\xc3\x80");
test_config_parse_path_one("not_absolute/path", NULL);