X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fpath-util.c;h=9e2fd6434a988512f9d75ee2c0c3ea2a9535116a;hb=c0e57ba9e22ee937722958d8b912ade2a37f206d;hp=b3fe0b81791f618949b4cbac1b183f3ba3e0b858;hpb=db594aef549b1376ea80030bd0966ed872eac01e;p=elogind.git diff --git a/src/shared/path-util.c b/src/shared/path-util.c index b3fe0b817..9e2fd6434 100644 --- a/src/shared/path-util.c +++ b/src/shared/path-util.c @@ -306,6 +306,7 @@ char **path_strv_resolve(char **l, const char *prefix) { } else { /* canonicalized path goes outside of * prefix, keep the original path instead */ + free(u); u = orig; orig = NULL; } @@ -439,14 +440,14 @@ char* path_join(const char *root, const char *path, const char *rest) { assert(path); if (!isempty(root)) - return strjoin(root, "/", + return strjoin(root, endswith(root, "/") ? "" : "/", path[0] == '/' ? path+1 : path, - rest ? "/" : NULL, + rest ? (endswith(path, "/") ? "" : "/") : NULL, rest && rest[0] == '/' ? rest+1 : rest, NULL); else return strjoin(path, - rest ? "/" : NULL, + rest ? (endswith(path, "/") ? "" : "/") : NULL, rest && rest[0] == '/' ? rest+1 : rest, NULL); } @@ -518,7 +519,7 @@ fallback: if (r < 0) return r; - r = lstat(parent, &b); + r = stat(parent, &b); if (r < 0) return -errno;