[PATCH] login-utils: use getdtablesize() correctly in login.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



while it might seem harmless to close a non-existent descriptor, we have
a local configuration that protects a certain descriptor by lowering
rlim_cur to prevent child processes from closing said descriptor. this
descriptor points to a ticket cache which we need later for the user.

Author: chas williams - CONTRACTOR <chas@xxxxxxxxxxxxxxxx>
Date:   Fri Apr 20 10:49:51 2012 -0400

    login-utils: use getdtablesize() correctly in login.c
    
    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@xxxxxxxxxxxxxxxx>

diff --git a/login-utils/login.c b/login-utils/login.c
index 6c3b6f7..026c72b 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -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 */
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux