From: Werner Fink Date: Thu, 8 May 2014 10:09:23 +0000 (+0200) Subject: sulogin: find a suitable console device X-Git-Tag: v2.25-rc1~174 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=624b204d7bdebdc5cac17d17830c397722c6dfea;p=thirdparty%2Futil-linux.git 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 --- 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);