From: Lubomir Rintel Date: Mon, 24 Jun 2019 18:38:30 +0000 (+0200) Subject: sd-device: don't accept /sys as a device path X-Git-Tag: v243~359 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c4f885e7e0a3e211b51b7b560674b1262f782c15;p=platform%2Fupstream%2Fsystemd.git 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) --- diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 773be6a..7d5d241 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -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;