diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-09-03 14:50:54 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-09-03 14:50:54 +0000 |
commit | b5f6f5d227ccf9ec76cc58f32cd6ae3c489f81b5 (patch) | |
tree | a032935b46fa755ea392eb399eb62f43206785ac /usr.sbin/syslogd | |
parent | 5e809207a670db0bea06da2d6f40a07afceacd7f (diff) |
Instead of creating a line buffer on the stack, tcp_readcb() can
use the global linebuf like the other libevent read callbacks.
OK jung@
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index a59d5fdc11b..d21d25662a9 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.181 2015/09/01 17:53:14 bluhm Exp $ */ +/* $OpenBSD: syslogd.c,v 1.182 2015/09/03 14:50:53 bluhm Exp $ */ /* * Copyright (c) 1983, 1988, 1993, 1994 @@ -1041,8 +1041,7 @@ void tcp_readcb(struct bufferevent *bufev, void *arg) { struct peer *p = arg; - char *msg, line[MAXLINE + 1]; - size_t linelen; + char *msg; int len; while (EVBUFFER_LENGTH(bufev->input) > 0) { @@ -1061,10 +1060,9 @@ tcp_readcb(struct bufferevent *bufev, void *arg) if (len > 0 && msg[len-1] == '\n') msg[len-1] = '\0'; if (len == 0 || msg[len-1] != '\0') { - linelen = MINIMUM((size_t)len, sizeof(line)-1); - memcpy(line, msg, linelen); - line[linelen] = '\0'; - msg = line; + memcpy(linebuf, msg, MINIMUM(len, MAXLINE)); + linebuf[MINIMUM(len, MAXLINE)] = '\0'; + msg = linebuf; } printline(p->p_hostname, msg); evbuffer_drain(bufev->input, len); |