diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-01-17 11:56:52 +0100 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-05-30 07:50:09 +0200 |
commit | d569509362723ee91d86feb0f139f2e874cce9d9 (patch) | |
tree | 843b1446ca9c19aa67ab56b4fc80cb386bf1aed4 /src/basic/fs-util.c | |
parent | 61d4da11b29f42434b10454355860d44e93b0f07 (diff) |
fs-util: extra safety checks on chase_symlinks() root parameter
Let's handle root="" and root="/" safely.
Diffstat (limited to 'src/basic/fs-util.c')
-rw-r--r-- | src/basic/fs-util.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index 32b1fb605..7a05e22ea 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -39,6 +39,7 @@ #include "mkdir.h" #include "parse-util.h" #include "path-util.h" +//#include "process-util.h" #include "stat-util.h" #include "stdio-util.h" #include "string-util.h" @@ -672,6 +673,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; |