diff options
author | 2015-09-03 14:50:53 +0000 | |
---|---|---|
committer | 2015-09-03 14:50:53 +0000 | |
commit | 4fc334f630ff4fa2329c2e937a490a74d2738414 (patch) | |
tree | e170a926fc01c13d0f36016c34707e8177344d77 | |
parent | A couple of style nits. (diff) | |
download | wireguard-openbsd-4fc334f630ff4fa2329c2e937a490a74d2738414.tar.xz wireguard-openbsd-4fc334f630ff4fa2329c2e937a490a74d2738414.zip |
Instead of creating a line buffer on the stack, tcp_readcb() can
use the global linebuf like the other libevent read callbacks.
OK jung@
-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); |