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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-05-05 17:15:04 +02:00
parent 3e2d0c6ab2
commit 52a89a5f08
+1 -1
View 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) &&