X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udev%2Flib%2Flibudev-device.c;h=055263bbef750232c22d48ff1b535f19ec634448;hb=1028fe14b65d861415cda99c4ff7d0bafd67bb7f;hp=eda3f5d97e26d8e3176849cc2432ca9f8b0cc2f0;hpb=77b852f3334311575b9c19ffb29d4a77a21b4bb2;p=elogind.git diff --git a/udev/lib/libudev-device.c b/udev/lib/libudev-device.c index eda3f5d97..055263bbe 100644 --- a/udev/lib/libudev-device.c +++ b/udev/lib/libudev-device.c @@ -501,9 +501,11 @@ static struct udev_device *device_new_from_parent(struct udev_device *udev_devic strncmp(udev_device->devpath, "/block/", 7) == 0) { util_strlcpy(path, udev_device->syspath, sizeof(path)); util_strlcat(path, "/device", sizeof(path)); - if (util_resolve_sys_link(udev_device->udev, path, sizeof(path)) == 0) + if (util_resolve_sys_link(udev_device->udev, path, sizeof(path)) == 0) { udev_device_parent = udev_device_new_from_syspath(udev_device->udev, path); - return udev_device_parent; + if (udev_device_parent != NULL) + return udev_device_parent; + } } util_strlcpy(path, udev_device->syspath, sizeof(path)); @@ -857,11 +859,16 @@ const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const } if (S_ISLNK(statbuf.st_mode)) { - /* links return the last element of the target path */ char target[UTIL_NAME_SIZE]; int len; char *pos; + /* some core links return the last element of the target path */ + if (strcmp(sysattr, "driver") != 0 && + strcmp(sysattr, "subsystem") != 0 && + strcmp(sysattr, "module") != 0) + goto out; + len = readlink(path, target, sizeof(target)); if (len > 0) { target[len] = '\0';