Index: lib/libc/gen/syslog.c =================================================================== --- lib/libc/gen/syslog.c +++ lib/libc/gen/syslog.c @@ -33,6 +33,9 @@ __SCCSID("@(#)syslog.c 8.5 (Berkeley) 4/29/95"); __FBSDID("$FreeBSD$"); +/* Maximum number of characters of syslog message */ +#define MAXLINE 8192 + #include "namespace.h" #include #include @@ -141,7 +144,7 @@ char ch, *p; long tz_offset; int cnt, fd, saved_errno; - char hostname[MAXHOSTNAMELEN], *stdp, tbuf[2048], fmt_cpy[1024], + char hostname[MAXHOSTNAMELEN], *stdp, tbuf[MAXLINE], errstr[64], tz_sign; FILE *fp, *fmt_fp; struct bufcookie tbuf_cookie; @@ -220,6 +223,7 @@ /* Check to see if we can skip expanding the %m */ if (strstr(fmt, "%m")) { + char fmt_cpy[MAXLINE]; /* Create the second stdio hook */ fmt_cookie.base = fmt_cpy; @@ -256,11 +260,12 @@ /* Guarantee null termination */ fmt_cpy[sizeof(fmt_cpy) - 1] = '\0'; - fmt = fmt_cpy; + /* Message. */ + (void)vfprintf(fp, fmt_cpy, ap); + } else { + /* Message. */ + (void)vfprintf(fp, fmt, ap); } - - /* Message. */ - (void)vfprintf(fp, fmt, ap); (void)fclose(fp); cnt = sizeof(tbuf) - tbuf_cookie.left; @@ -396,9 +401,19 @@ struct sockaddr_un SyslogAddr; /* AF_UNIX address of local logger */ if (LogFile == -1) { + socklen_t len; + if ((LogFile = _socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0)) == -1) return; + if (_getsockopt(LogFile, SOL_SOCKET, SO_SNDBUF, &len, + &(socklen_t){sizeof(len)}) == 0) { + if (len < MAXLINE) { + len = MAXLINE; + (void)_setsockopt(LogFile, SOL_SOCKET, SO_SNDBUF, + &len, sizeof(len)); + } + } } if (LogFile != -1 && status == NOCONN) { SyslogAddr.sun_len = sizeof(SyslogAddr);