]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
path-util: use path_is_safe() in path_is_normalized()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 30 Apr 2021 17:55:20 +0000 (02:55 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 28 May 2021 04:41:23 +0000 (13:41 +0900)
src/basic/path-util.c

index 48535da7256724a2d84d8c95eb04e0decd1c0b86..4b83232df882fd7796203b5c97add7be2a131fb0 100644 (file)
@@ -1057,17 +1057,10 @@ bool path_is_valid_full(const char *p, bool accept_dot_dot) {
 }
 
 bool path_is_normalized(const char *p) {
-
-        if (!path_is_valid(p))
-                return false;
-
-        if (dot_or_dot_dot(p))
-                return false;
-
-        if (startswith(p, "../") || endswith(p, "/..") || strstr(p, "/../"))
+        if (!path_is_safe(p))
                 return false;
 
-        if (startswith(p, "./") || endswith(p, "/.") || strstr(p, "/./"))
+        if (streq(p, ".") || startswith(p, "./") || endswith(p, "/.") || strstr(p, "/./"))
                 return false;
 
         if (strstr(p, "//"))