From: chas williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
To: "util-linux@vger.kernel.org" <util-linux@vger.kernel.org>
Subject: [PATCH] login-utils: use getdtablesize() correctly in login.c
Date: Fri, 20 Apr 2012 10:58:28 -0400 [thread overview]
Message-ID: <20120420105828.554ce55a@thirdoffive.cmf.nrl.navy.mil> (raw)
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 */
next reply other threads:[~2012-04-20 15:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-20 14:58 chas williams - CONTRACTOR [this message]
2012-04-23 12:02 ` [PATCH] login-utils: use getdtablesize() correctly in login.c Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120420105828.554ce55a@thirdoffive.cmf.nrl.navy.mil \
--to=chas@cmf.nrl.navy.mil \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox