From c4f885e7e0a3e211b51b7b560674b1262f782c15 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 24 Jun 2019 20:38:30 +0200 Subject: [PATCH] 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) --- src/libsystemd/sd-device/sd-device.c | 4 ++++ 1 file changed, 4 insertions(+) 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; -- 2.7.4