sd-device: do not trigger assertion by a bad udev rules

The assertion can be triggered by bad `$attr{[<subsys>/<sysname>]<attribute>}`
formatting. That's not a programmer's error, but a runtime error.

Prompted by #30029.
This commit is contained in:
Yu Watanabe
2023-11-16 02:32:12 +09:00
parent c0b927eb3a
commit aecedc48a6
+7 -2
View File
@@ -422,8 +422,13 @@ _public_ int sd_device_new_from_subsystem_sysname(
int r;
assert_return(ret, -EINVAL);
assert_return(path_is_normalized(subsystem), -EINVAL);
assert_return(path_is_normalized(sysname), -EINVAL);
assert_return(subsystem, -EINVAL);
assert_return(sysname, -EINVAL);
if (!path_is_normalized(subsystem))
return -EINVAL;
if (!path_is_normalized(sysname))
return -EINVAL;
/* translate sysname back to sysfs filename */
name = strdupa_safe(sysname);