From 92e5ba438d48a798807104d8aed4e480c58c6465 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Wed, 5 May 2021 17:02:49 +0200
Subject: [PATCH] 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.

(cherry picked from commit 52a89a5f08230439f07c043d59ded1270842137b)
Conflict:NA
Reference:https://github.com/systemd/systemd-stable/commit/92e5ba438d48a798807104d8aed4e480c58c6465
---
 src/libsystemd/sd-device/sd-device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
index c041660faf..d82f01a164 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) &&
-- 
2.27.0

