From: Lennart Poettering Date: Mon, 26 Feb 2018 17:34:43 +0000 (+0100) Subject: logind: check file is device node before using .st_rdev X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=fb52e9446e570146735876aa9b38e617316ea36f;p=elogind.git logind: check file is device node before using .st_rdev --- diff --git a/src/login/logind.c b/src/login/logind.c index ed250bc2a..481c5e40e 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -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