]> 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>
Thu, 24 May 2012 10:17:51 +0000 (12:17 +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 043eaa20a711abcfd5d8dc24c4c9f317b4dbf911..a984af62e4c9ef246c7e41bd6a420ae1d92107dc 100644 (file)
@@ -1289,7 +1289,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 */