fs-util: extra chase_symlink() safety check on "path" parameter
authorLennart Poettering <lennart@poettering.net>
Wed, 17 Jan 2018 11:00:12 +0000 (12:00 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 17 Jan 2018 11:04:15 +0000 (12:04 +0100)
It's not clear what an empty "path" is even supposed to mean, hence
refuse.

src/basic/fs-util.c

index 15f9958..f0df79d 100644 (file)
@@ -637,6 +637,9 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
         if ((flags & (CHASE_NONEXISTENT|CHASE_OPEN)) == (CHASE_NONEXISTENT|CHASE_OPEN))
                 return -EINVAL;
 
+        if (isempty(path))
+                return -EINVAL;
+
         /* This is a lot like canonicalize_file_name(), but takes an additional "root" parameter, that allows following
          * symlinks relative to a root directory, instead of the root of the host.
          *