]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
load-fragment: validate paths properly
authorLennart Poettering <lennart@poettering.net>
Tue, 25 May 2021 15:25:40 +0000 (17:25 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 25 May 2021 22:19:50 +0000 (23:19 +0100)
The comment suggests we validate paths here, but we actually didn't, we
only validated filenames. Let' fix that.

(Note this still lets any kind of paths through, including those with
".." and stuff, this is not a normalization check after all)

src/core/load-fragment.c

index 72378a408276daf6abc3ac590d3d956c39f258f2..ff6eaf32ef6233d2ccc71fb847feaa843ff04832 100644 (file)
@@ -789,7 +789,7 @@ int config_parse_exec(
                         return ignore ? 0 : -ENOEXEC;
                 }
 
-                if (!path_is_absolute(path) && !filename_is_valid(path)) {
+                if (!(path_is_absolute(path) ? path_is_valid(path) : filename_is_valid(path))) {
                         log_syntax(unit, ignore ? LOG_WARNING : LOG_ERR, filename, line, 0,
                                    "Neither a valid executable name nor an absolute path%s: %s",
                                    ignore ? ", ignoring" : "", path);