summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-01-17 11:56:52 +0100
committerLennart Poettering <lennart@poettering.net>2018-01-17 12:04:15 +0100
commitb1bfb848046e457f3cd623286b8cc1a5e5440023 (patch)
treeb1e8f600d20c6e53f68ba28669c999109583725c /src
parentefivars: include errno.h when EFI support is disabled (#7900) (diff)
downloadsystemd-b1bfb848046e457f3cd623286b8cc1a5e5440023.tar.xz
systemd-b1bfb848046e457f3cd623286b8cc1a5e5440023.zip
fs-util: extra safety checks on chase_symlinks() root parameter
Let's handle root="" and root="/" safely.
Diffstat (limited to '')
-rw-r--r--src/basic/fs-util.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c
index 068f5660fa..15f9958c05 100644
--- a/src/basic/fs-util.c
+++ b/src/basic/fs-util.c
@@ -658,6 +658,14 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
* specified path. */
if (original_root) {
+ if (isempty(original_root)) /* What's this even supposed to mean? */
+ return -EINVAL;
+
+ if (path_equal(original_root, "/")) /* A root directory of "/" is identical to none */
+ original_root = NULL;
+ }
+
+ if (original_root) {
r = path_make_absolute_cwd(original_root, &root);
if (r < 0)
return r;