sd-device: make devpath check stricter 61/300861/1 accepted/tizen_unified_riscv accepted/tizen/unified/20231107.172850 accepted/tizen/unified/riscv/20231215.050346
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 18 Feb 2021 15:41:08 +0000 (00:41 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Fri, 3 Nov 2023 02:01:17 +0000 (11:01 +0900)
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 <y0.cho@samsung.com>
src/libsystemd/sd-device/sd-device.c

index 04696f4..7a93125 100644 (file)
@@ -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;