Hi,
Instead of creating a line buffer on the stack, tcp_readcb() can
use the global linebuf like the other read callbacks.
ok?
bluhm
Index: usr.sbin/syslogd/syslogd.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.181
diff -u -p -r1.181 syslogd.c
--- usr.sbin/syslogd/syslogd.c 1 Sep 2015 17:53:14 -0000 1.181
+++ usr.sbin/syslogd/syslogd.c 1 Sep 2015 19:19:26 -0000
@@ -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, vo
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);