diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-04-05 10:18:17 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2022-04-11 16:26:58 +0200 |
commit | 4d960d0bdb373b6bb71f77f8a3032795d60284c3 (patch) | |
tree | 401fb1bf2d425b8c368f91222922cc17093d7806 /src/libsystemd/sd-device | |
parent | 09c24f76dce5f606056d916207676f2a93157deb (diff) | |
download | systemd-4d960d0bdb373b6bb71f77f8a3032795d60284c3.tar.gz |
sd-device: make device_set_syspath() more defensive
Simplify generated sysfs paths, since we might get data passed that
includes extra // in the middle.
Also, let's not assume /sys/ prefix without verification.
Diffstat (limited to 'src/libsystemd/sd-device')
-rw-r--r-- | src/libsystemd/sd-device/sd-device.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 89c5b2cdd3..f9c491c242 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -207,10 +207,11 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) { syspath = strdup(_syspath); if (!syspath) return log_oom_debug(); - } - devpath = syspath + STRLEN("/sys"); + path_simplify(syspath); + } + assert_se(devpath = startswith(syspath, "/sys")); if (devpath[0] != '/') return log_debug_errno(SYNTHETIC_ERRNO(ENODEV), "sd-device: \"/sys\" alone is not a valid device path."); |