X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbasic%2Fpath-util.c;h=8cb013e6cb2beea724909568d0ca6bed93a55045;hb=a683e1878913969ccf8b0defdec4d955e15ed75a;hp=3af2bd0fd4ab82aeb5ede0d7fbd8274f2a9285d2;hpb=d96290d8fd01ba77eec7f4a5fb493bc1ff80a98b;p=elogind.git diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 3af2bd0fd..8cb013e6c 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -290,9 +290,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; + free_and_replace(u, orig); } } else free(t); @@ -358,6 +356,16 @@ char* path_startswith(const char *path, const char *prefix) { assert(path); assert(prefix); + /* Returns a pointer to the start of the first component after the parts matched by + * the prefix, iff + * - both paths are absolute or both paths are relative, + * and + * - each component in prefix in turn matches a component in path at the same position. + * An empty string will be returned when the prefix and path are equivalent. + * + * Returns NULL otherwise. + */ + if ((path[0] == '/') != (prefix[0] == '/')) return NULL; @@ -826,7 +834,6 @@ bool is_deviceallow_pattern(const char *path) { startswith(path, "block-") || startswith(path, "char-"); } -#endif // 0 int systemd_installation_has_version(const char *root, unsigned minimal_version) { const char *pattern; @@ -893,3 +900,4 @@ int systemd_installation_has_version(const char *root, unsigned minimal_version) return false; } +#endif // 0