diff options
author | Florian Zumbiehl <florz@florz.de> | 2009-08-30 21:40:13 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2009-08-30 21:40:13 +0200 |
commit | 4c21b7156d951c99fe8d57a36bf3b006cc3d3a73 (patch) | |
tree | aa6272c69534a109f3b371643381ea85f129288a | |
parent | ebc1ba78edd35a5973f2671a80a71639f5949212 (diff) |
util_create_path(): fix possible out of bounds array access
-rw-r--r-- | libudev/libudev-util-private.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libudev/libudev-util-private.c b/libudev/libudev-util-private.c index 042b711928..fe8f29b3a8 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); |