From: Yu Watanabe Date: Wed, 15 Nov 2023 17:27:19 +0000 (+0900) Subject: sd-device: do not trigger assertion by a bad udev rules X-Git-Tag: v255-rc3~59^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F30040%2Fhead;p=thirdparty%2Fsystemd.git sd-device: do not trigger assertion by a bad udev rules The assertion can be triggered by bad `$attr{[/]}` formatting. That's not a programmer's error, but a runtime error. Prompted by #30029. --- diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 75725a75b3d..2fbc619a34d 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -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);