chiark / gitweb /
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)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:50:10 +0000 (07:50 +0200)
It's not clear what an empty "path" is even supposed to mean, hence
refuse.

src/basic/fs-util.c

index 7a05e22ea52aa903cfcc20714cdac50834406f9c..bbc464e31c8de935d6f7a09affd800af53c1cd4d 100644 (file)
@@ -652,6 +652,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.
          *