From 4c21b7156d951c99fe8d57a36bf3b006cc3d3a73 Mon Sep 17 00:00:00 2001 From: Florian Zumbiehl Date: Sun, 30 Aug 2009 21:40:13 +0200 Subject: [PATCH] util_create_path(): fix possible out of bounds array access --- libudev/libudev-util-private.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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); -- 2.39.5