]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/chase.c
Merge pull request #27918 from yuwata/chase-filename
[thirdparty/systemd.git] / src / basic / chase.c
index 2a1bada4363c1d0db13c0089af190438c425399a..02b52791cecd678eb138e82e68ca0eda2145a03e 100644 (file)
@@ -206,7 +206,7 @@ int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int
         /* If we receive an absolute path together with AT_FDCWD, we need to return an absolute path, because
          * a relative path would be interpreted relative to the current working directory. Also, let's make
          * the result absolute when the file descriptor of the root directory is specified. */
-        bool need_absolute = (dir_fd == AT_FDCWD && path_is_absolute(path)) || dir_fd_is_root(dir_fd) > 0;
+        bool need_absolute = (dir_fd == AT_FDCWD && path_is_absolute(path)) || (dir_fd >= 0 && dir_fd_is_root(dir_fd) > 0);
         if (need_absolute) {
                 done = strdup("/");
                 if (!done)