]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sulogin: make sure that fallback FD is valid [coverity scan]
authorKarel Zak <kzak@redhat.com>
Thu, 29 Jan 2015 10:32:42 +0000 (11:32 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 29 Jan 2015 10:32:42 +0000 (11:32 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/sulogin-consoles.c

index 817a882cf73c1891bad622fe12206c1e19421f88..9fd10340562410a5d1e09d58738d33e1007dfe25 100644 (file)
@@ -594,7 +594,7 @@ int detect_consoles(const char *device, int fallback, struct list_head *consoles
        consoles_debug = getenv("CONSOLES_DEBUG") ? 1 : 0;
 
        if (!device || !*device)
-               fd = dup(fallback);
+               fd = fallback >= 0 ? dup(fallback) : - 1;
        else {
                fd = open(device, O_RDWR|O_NONBLOCK|O_NOCTTY|O_CLOEXEC);
                reconnect = 1;