diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2006-09-17 18:28:35 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2006-09-17 18:28:35 +0000 |
commit | 4608ddf94118f127a3e5399b1bcbbd2bbc0b0abe (patch) | |
tree | 78a912662b10fff32dd3dbf0fe458dbbad09d510 /usr.sbin/syslogd | |
parent | 591eba2ef97f449b76516339bea0e7f78b489f31 (diff) |
check that stdio file descriptors are actually closed before clobbering
them, following an identical change in openssh
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 70d5b99e2ee..b8ae34eee7b 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.92 2005/06/10 01:41:43 millert Exp $ */ +/* $OpenBSD: syslogd.c,v 1.93 2006/09/17 18:28:34 djm Exp $ */ /* * Copyright (c) 1983, 1988, 1993, 1994 @@ -39,7 +39,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94"; #else -static const char rcsid[] = "$OpenBSD: syslogd.c,v 1.92 2005/06/10 01:41:43 millert Exp $"; +static const char rcsid[] = "$OpenBSD: syslogd.c,v 1.93 2006/09/17 18:28:34 djm Exp $"; #endif #endif /* not lint */ @@ -330,13 +330,14 @@ main(int argc, char *argv[]) if (Debug) setlinebuf(stdout); - if ((nullfd = open(_PATH_DEVNULL, O_RDWR)) == -1) { + if ((fd = nullfd = open(_PATH_DEVNULL, O_RDWR)) == -1) { logerror("Couldn't open /dev/null"); die(0); } - while (nullfd < 2) { - dup2(nullfd, nullfd + 1); - nullfd++; + while (fd++ <= 2) { + if (fcntl(fd, F_GETFL, 0) == -1) + if (dup2(nullfd, fd) == -1) + logerror("dup2"); } consfile.f_type = F_CONSOLE; |