]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: reject empty driver name 19515/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 5 May 2021 15:02:49 +0000 (17:02 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 5 May 2021 15:15:04 +0000 (17:15 +0200)
If ":" was the last char in the string, we would call access() on ".../drivers/", which
would pass. It probably doesn't matter, but let's reject this anyway.

src/libsystemd/sd-device/sd-device.c

index 16c518fced86afe0551d58072d0afb8d538e87e5..d0cba5b86009f07239f52d39041bfa902965a6d9 100644 (file)
@@ -274,7 +274,7 @@ _public_ int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *s
                 const char *subsys, *sep;
 
                 sep = strchr(sysname, ':');
-                if (sep) {
+                if (sep && sep[1] != '\0') { /* Require ":" and something non-empty after that. */
                         subsys = memdupa_suffix0(sysname, sep - sysname);
 
                         if (snprintf_ok(syspath, sizeof syspath, "/sys/subsystem/%s/drivers/%s", subsys, sep + 1) &&