sd-device: don't accept /sys as a device path
Because it's not a device path and (slightly) bad things happen if it gets confused with one: $ udevadm info /sys/ Assertion 'device->devpath[0] == '/'' failed at ../src/libsystemd/sd-device/sd-device.c:958, function sd_device_get_devpath(). Aborting. Aborted (core dumped)
This commit is contained in:
parent
f053fc337e
commit
c4f885e7e0
|
@ -201,6 +201,10 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) {
|
|||
|
||||
devpath = syspath + STRLEN("/sys");
|
||||
|
||||
if (devpath[0] == '\0')
|
||||
/* '/sys' alone is not a valid device path */
|
||||
return -ENODEV;
|
||||
|
||||
r = device_add_property_internal(device, "DEVPATH", devpath);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
|
Loading…
Reference in a new issue