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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user