X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=libudev%2Flibudev-util-private.c;h=fe8f29b3a89007e20b595a73693644e4b18484ca;hb=32ecabb15d76bd9db8f7d15dcd39807383a93934;hp=c86567159eaf98a5886b67371bb1cb152bf98419;hpb=28da1a6186fcb55762b1649c6dd1e43545e0eb9a;p=elogind.git diff --git a/libudev/libudev-util-private.c b/libudev/libudev-util-private.c index c86567159..fe8f29b3a 100644 --- a/libudev/libudev-util-private.c +++ b/libudev/libudev-util-private.c @@ -34,11 +34,12 @@ int util_create_path(struct udev *udev, const char *path) util_strscpy(p, sizeof(p), path); pos = strrchr(p, '/'); - if (pos == p || pos == NULL) + if (pos == NULL) return 0; - - while (pos[-1] == '/') + while (pos != p && pos[-1] == '/') pos--; + if (pos == p) + return 0; pos[0] = '\0'; dbg(udev, "stat '%s'\n", p); @@ -64,6 +65,9 @@ int util_delete_path(struct udev *udev, const char *path) char *pos; int retval; + if (path[0] == '/') + while(path[1] == '/') + path++; util_strscpy(p, sizeof(p), path); pos = strrchr(p, '/'); if (pos == p || pos == NULL)