chiark / gitweb /
logind: check file is device node before using .st_rdev
authorLennart Poettering <lennart@poettering.net>
Mon, 26 Feb 2018 17:34:43 +0000 (18:34 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:59:06 +0000 (07:59 +0200)
src/login/logind.c

index ed250bc2ab4dc42d98975ff3eecad357f0b459a4..481c5e40e58584f55276d0ad0d71843497f407e3 100644 (file)
@@ -480,6 +480,12 @@ static int manager_attach_fds(Manager *m) {
                         continue;
                 }
 
+                if (!S_ISCHR(st.st_mode) && !S_ISBLK(st.st_mode)) {
+                        log_debug("Device fd doesn't actually point to device node: %m");
+                        close_nointr(fd);
+                        continue;
+                }
+
                 sd = hashmap_get(s->devices, &st.st_rdev);
                 if (!sd) {
                         /* Weird, we got an fd for a session device which wasn't