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.
(cherry picked from commit
52a89a5f08230439f07c043d59ded1270842137b)
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) &&