summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-05-05 17:02:49 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-05-05 17:15:04 +0200
commit52a89a5f08230439f07c043d59ded1270842137b (patch)
tree5039899125df9c0315ba94db75086b04dabc67ce /src/libsystemd
parent3e2d0c6ab2abc0ab85440580931b2462bb73cfda (diff)
downloadsystemd-52a89a5f08230439f07c043d59ded1270842137b.tar.gz
sd-device: reject empty driver name
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.
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-device/sd-device.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
index 16c518fced..d0cba5b860 100644
--- a/src/libsystemd/sd-device/sd-device.c
+++ b/src/libsystemd/sd-device/sd-device.c
@@ -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) &&