From: Florian Zumbiehl Date: Sun, 30 Aug 2009 19:40:13 +0000 (+0200) Subject: util_create_path(): fix possible out of bounds array access X-Git-Tag: 174~804 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c21b7156d951c99fe8d57a36bf3b006cc3d3a73;p=systemd util_create_path(): fix possible out of bounds array access --- diff --git a/libudev/libudev-util-private.c b/libudev/libudev-util-private.c index 042b7119..fe8f29b3 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);