summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syslogd
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2017-09-17 22:25:21 +0000
committerbluhm <bluhm@openbsd.org>2017-09-17 22:25:21 +0000
commit469a3b90a3dd59962db2e378f8e313a6e50dedea (patch)
tree13ecfc359e99dacfc2f365d376a93a0eb6e04680 /usr.sbin/syslogd
parentOops. Missed a file. (diff)
downloadwireguard-openbsd-469a3b90a3dd59962db2e378f8e313a6e50dedea.tar.xz
wireguard-openbsd-469a3b90a3dd59962db2e378f8e313a6e50dedea.zip
When writing local output, syslogd ignores EAGAIN. Unfortunately
it has closed the file descriptor before checking the errno. So f_file contained a bad file descriptor that could be reused at the next open. Keep the file open if errno is EAGAIN. Move the close(2) down where the old file descriptor in f_file is overwritten in all cases. OK deraadt@ jca@
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r--usr.sbin/syslogd/syslogd.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 1b66f5b9f6a..47cebbd2645 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syslogd.c,v 1.246 2017/09/12 15:17:20 bluhm Exp $ */
+/* $OpenBSD: syslogd.c,v 1.247 2017/09/17 22:25:21 bluhm Exp $ */
/*
* Copyright (c) 1983, 1988, 1993, 1994
@@ -2045,7 +2045,6 @@ fprintlog(struct filed *f, int flags, char *msg)
break;
}
- (void)close(f->f_file);
/*
* Check for errors on TTY's or program pipes.
* Errors happen due to loss of tty or died programs.
@@ -2056,7 +2055,10 @@ fprintlog(struct filed *f, int flags, char *msg)
* This can happen when logging to a locked tty.
*/
break;
- } else if ((e == EIO || e == EBADF) &&
+ }
+
+ (void)close(f->f_file);
+ if ((e == EIO || e == EBADF) &&
f->f_type != F_FILE && f->f_type != F_PIPE &&
!retryonce) {
f->f_file = priv_open_tty(f->f_un.f_fname);