* [PATCH] login-utils: use getdtablesize() correctly in login.c
@ 2012-04-20 14:58 chas williams - CONTRACTOR
2012-04-23 12:02 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: chas williams - CONTRACTOR @ 2012-04-20 14:58 UTC (permalink / raw)
To: util-linux@vger.kernel.org
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@cmf.nrl.navy.mil>
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@cmf.nrl.navy.mil>
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 */
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-04-23 12:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-20 14:58 [PATCH] login-utils: use getdtablesize() correctly in login.c chas williams - CONTRACTOR
2012-04-23 12:02 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox