1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-25 18:50:18 +03:00

util_create_path(): fix possible out of bounds array access

This commit is contained in:
Florian Zumbiehl 2009-08-30 21:40:13 +02:00 committed by Kay Sievers
parent ebc1ba78ed
commit 4c21b7156d

View File

@ -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);