summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syslogd
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2017-03-16 12:14:37 +0000
committerbluhm <bluhm@openbsd.org>2017-03-16 12:14:37 +0000
commitcba42f65ce1803103f6a31c6f6970dfb4c9e4374 (patch)
tree86d485273fa774742f197f25a343434307e9988e /usr.sbin/syslogd
parentUserland expects pltime to be a time stamp not number of seconds. (diff)
downloadwireguard-openbsd-cba42f65ce1803103f6a31c6f6970dfb4c9e4374.tar.xz
wireguard-openbsd-cba42f65ce1803103f6a31c6f6970dfb4c9e4374.zip
There was a file descripotor leak in the syslogd(8) ttymsg() error
path. Before returning early with an error, close the newly opened file descriptor. OK deraadt@
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r--usr.sbin/syslogd/ttymsg.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.sbin/syslogd/ttymsg.c b/usr.sbin/syslogd/ttymsg.c
index e7c0738bb97..903bfc746fd 100644
--- a/usr.sbin/syslogd/ttymsg.c
+++ b/usr.sbin/syslogd/ttymsg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ttymsg.c,v 1.11 2016/08/16 18:41:57 tedu Exp $ */
+/* $OpenBSD: ttymsg.c,v 1.12 2017/03/16 12:14:37 bluhm Exp $ */
/* $NetBSD: ttymsg.c,v 1.3 1994/11/17 07:17:55 jtc Exp $ */
/*
@@ -137,7 +137,7 @@ ttymsg(struct iovec *iov, int iovcnt, char *utline)
if (tty_delayed >= TTYMAXDELAY) {
(void) snprintf(ebuf, sizeof(ebuf),
"%s: too many delayed writes", device);
- return (ebuf);
+ goto error;
}
logdebug("ttymsg delayed write\n");
if (iov != localiov) {
@@ -148,7 +148,7 @@ ttymsg(struct iovec *iov, int iovcnt, char *utline)
if ((td = malloc(sizeof(*td))) == NULL) {
(void) snprintf(ebuf, sizeof(ebuf),
"%s: malloc: %s", device, strerror(errno));
- return (ebuf);
+ goto error;
}
td->td_length = 0;
if (left > MAXLINE)
@@ -176,9 +176,10 @@ ttymsg(struct iovec *iov, int iovcnt, char *utline)
*/
if (errno == ENODEV || errno == EIO)
break;
- (void) close(fd);
(void) snprintf(ebuf, sizeof(ebuf),
"%s: %s", device, strerror(errno));
+ error:
+ (void) close(fd);
return (ebuf);
}