From 458e60b3a91cfeb72163a312187ce672a9c4dfe0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 7 Mar 2019 10:37:04 +0100 Subject: [PATCH] path-util: check validity before normalization in path_simplify_and_warn() As the normalization check includes a validation check the order matters. --- src/basic/path-util.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 221517303e..084e0a9f29 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -1132,13 +1132,6 @@ int path_simplify_and_warn( path_simplify(path, true); - if (!path_is_normalized(path)) { - log_syntax(unit, LOG_ERR, filename, line, 0, - "%s= path is not normalized%s: %s", - lvalue, fatal ? "" : ", ignoring", path); - return -EINVAL; - } - if (!path_is_valid(path)) { log_syntax(unit, LOG_ERR, filename, line, 0, "%s= path has invalid length (%zu bytes)%s.", @@ -1146,5 +1139,12 @@ int path_simplify_and_warn( return -EINVAL; } + if (!path_is_normalized(path)) { + log_syntax(unit, LOG_ERR, filename, line, 0, + "%s= path is not normalized%s: %s", + lvalue, fatal ? "" : ", ignoring", path); + return -EINVAL; + } + return 0; }