The branch stable/13 has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2886c93d1bca231260ebc01d4205743ca781f3c7

commit 2886c93d1bca231260ebc01d4205743ca781f3c7
Author:     Dmitry Wagin <[email protected]>
AuthorDate: 2021-03-23 16:01:15 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2021-05-14 13:56:46 +0000

    libc: Some enhancements to syslog(3)
    
    - Defined MAXLINE constant (8192 octets by default instead 2048) for
      centralized limit setting up. It sets maximum number of characters of
      the syslog message. RFC5424 doesn't limit maximum size of the message.
      Named after MAXLINE in syslogd(8).
    - Fixed size of fmt_cpy buffer up to MAXLINE for rendering formatted
      (%m) messages.
    - Introduced autoexpansion of sending socket buffer up to MAXLINE.
    
    Differential Revision:  https://reviews.freebsd.org/D27205
    
    (cherry picked from commit 9bd7345212203924046009e29ce3f1515556f989)
---
 lib/libc/gen/syslog.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c
index 19d44db0075a..797c7389d1a2 100644
--- a/lib/libc/gen/syslog.c
+++ b/lib/libc/gen/syslog.c
@@ -57,6 +57,9 @@ __FBSDID("$FreeBSD$");
 
 #include "libc_private.h"
 
+/* Maximum number of characters of syslog message */
+#define        MAXLINE         8192
+
 static int     LogFile = -1;           /* fd for log */
 static int     status;                 /* connection status */
 static int     opened;                 /* have done openlog() */
@@ -141,7 +144,7 @@ vsyslog1(int pri, const char *fmt, va_list ap)
        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], fmt_cpy[MAXLINE],
            errstr[64], tz_sign;
        FILE *fp, *fmt_fp;
        struct bufcookie tbuf_cookie;
@@ -396,9 +399,19 @@ connectlog(void)
        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);
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to