mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
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.
This commit is contained in:
@@ -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();
|
||||
|
||||
path_simplify(syspath);
|
||||
}
|
||||
|
||||
devpath = syspath + STRLEN("/sys");
|
||||
|
||||
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.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user