chiark / gitweb /
fs-util: small tweak in chase_symlinks()
authorLennart Poettering <lennart@poettering.net>
Wed, 4 Oct 2017 15:34:03 +0000 (17:34 +0200)
committerSven Eden <yamakuzure@gmx.net>
Wed, 4 Oct 2017 15:34:03 +0000 (17:34 +0200)
If we follow an absolute symlink there's no need to prefix the path with
a "/", since by definition it already has one.

This helps suppressing double "/" in resolved paths containing absolute
symlinks.

src/basic/fs-util.c

index 28b2dce33867498c7049c4d45c5b69b14711a496..d63eeb1d2df4ed32e18112cd4d53e62ad8bf148e 100644 (file)
@@ -781,12 +781,11 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
                                                 return -ENOMEM;
                                 }
 
-                        }
-
-                        /* Prefix what's left to do with what we just read, and start the loop again,
-                         * but remain in the current directory. */
-
-                        joined = strjoin("/", destination, todo);
+                                /* Prefix what's left to do with what we just read, and start the loop again, but
+                                 * remain in the current directory. */
+                                joined = strjoin(destination, todo);
+                        } else
+                                joined = strjoin("/", destination, todo);
                         if (!joined)
                                 return -ENOMEM;