From 27fcee36f95f4a0475b8b5f2e7c08024b942cf95 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 19 Feb 2021 00:41:08 +0900 Subject: sd-device: make devpath check stricter See assertion in sd_device_get_devpath(). (Backporting comment) There sometimes and empty devpath comes from the function. See the deviced commit, 2628c5aed5c0e712e1fbd7d571ef0b640f5afbec. Original: upstream, https://github.com/systemd/systemd/pull/18684 Change-Id: I29816219b3fc40eb13c1bf4bbb5d84b9782da333 Signed-off-by: Youngjae Cho --- src/libsystemd/sd-device/sd-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 04696f4bc1..7a93125c2f 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -201,7 +201,7 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) { devpath = syspath + STRLEN("/sys"); - if (devpath[0] == '\0') + if (devpath[0] != '/') /* '/sys' alone is not a valid device path */ return -ENODEV; -- cgit v1.2.3