From 624b204d7bdebdc5cac17d17830c397722c6dfea Mon Sep 17 00:00:00 2001 From: Werner Fink Date: Thu, 8 May 2014 12:09:23 +0200 Subject: [PATCH] sulogin: find a suitable console device Enable sulogin to find a suitable console device even if the first line in /proc/consoles does not have any major and minor number. Signed-off-by: Werner Fink --- login-utils/sulogin-consoles.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/login-utils/sulogin-consoles.c b/login-utils/sulogin-consoles.c index 6ceea6ba79..817a882cf7 100644 --- a/login-utils/sulogin-consoles.c +++ b/login-utils/sulogin-consoles.c @@ -324,7 +324,7 @@ static int detect_consoles_from_proc(struct list_head *consoles) char fbuf[16 + 1]; DIR *dir = NULL; FILE *fc = NULL; - int maj, min, rc = 1; + int maj, min, rc = 1, matches; DBG(dbgprint("trying /proc")); @@ -337,10 +337,12 @@ static int detect_consoles_from_proc(struct list_head *consoles) if (!dir) goto done; - while (fscanf(fc, "%*s %*s (%16[^)]) %d:%d", fbuf, &maj, &min) == 3) { + while ((matches = fscanf(fc, "%*s %*s (%16[^)]) %d:%d", fbuf, &maj, &min)) >= 1) { char *name; dev_t comparedev; + if (matches != 3) + continue; if (!strchr(fbuf, 'E')) continue; comparedev = makedev(maj, min); -- 2.47.3