On Fri, Jun 12, 2015 at 12:53:34PM -0600, Todd C. Miller wrote:
> > I wanted both places were we close the lockpipe in a consistent
> > order. Now I think we should compare the fd with 2 in both places
> > to have the same level of paranoia as with nullfd a few lines below.
>
> It is safer to close the lock fd first for the following reasons:
>
> 1) No need to check whether it might be in the range 0-2.
>
> 2) You free up a free fd slot in case resource limits are
> low.
You are right. Then this is the correct diff. ok?
bluhm
Index: usr.sbin/syslogd/syslogd.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.162
diff -u -p -r1.162 syslogd.c
--- usr.sbin/syslogd/syslogd.c 12 Jun 2015 00:54:28 -0000 1.162
+++ usr.sbin/syslogd/syslogd.c 12 Jun 2015 18:59:17 -0000
@@ -629,10 +629,10 @@ main(int argc, char *argv[])
reply_text = ctl_reply + CTL_HDR_LEN;
if (!Debug) {
+ close(lockpipe[1]);
dup2(nullfd, STDIN_FILENO);
dup2(nullfd, STDOUT_FILENO);
dup2(nullfd, STDERR_FILENO);
- close(lockpipe[1]);
}
if (nullfd > 2)
close(nullfd);