]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: use getdtablesize() correctly in login.c
authorchas williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Fri, 20 Apr 2012 14:58:28 +0000 (10:58 -0400)
committerKarel Zak <kzak@redhat.com>
Mon, 23 Apr 2012 11:33:00 +0000 (13:33 +0200)
getdtablesize() is the number of descriptors and since decriptors start
at 0, its value isnt the largest descriptors possible.  One should use
getdtablesize() - 1 instead.

Signed-off-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
login-utils/login.c

index bb977e5d9eb21688d4e2874e853bcc2f22fa6502..e2c0f8015c6e0d4e5974fdb4defe536a7403cb89 100644 (file)
@@ -1290,7 +1290,7 @@ int main(int argc, char **argv)
                        *p++ = ' ';
        }
 
-       for (cnt = getdtablesize(); cnt > 2; cnt--)
+       for (cnt = (getdtablesize() - 1); cnt > 2; cnt--)
                close(cnt);
 
        setpgrp();       /* set pgid to pid this means that setsid() will fail */