]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
syslog: Fix integer overflow in __vsyslog_internal (CVE-2023-6780)
authorArjun Shankar <arjun@redhat.com>
Mon, 15 Jan 2024 16:44:45 +0000 (17:44 +0100)
committerArjun Shankar <arjun@redhat.com>
Tue, 30 Jan 2024 14:53:37 +0000 (15:53 +0100)
__vsyslog_internal calculated a buffer size by adding two integers, but
did not first check if the addition would overflow.  This commit fixes
that.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
misc/syslog.c

index 53440e47ad459085ea196efcddf8b9a7af3dcba0..4af87f54fdbe49bec65c637cab3a6e2397fe33ba 100644 (file)
@@ -41,6 +41,7 @@ static char sccsid[] = "@(#)syslog.c  8.4 (Berkeley) 3/18/94";
 #include <sys/uio.h>
 #include <sys/un.h>
 #include <syslog.h>
+#include <limits.h>
 
 static int LogType = SOCK_DGRAM;       /* type of socket connection */
 static int LogFile = -1;               /* fd for log */
@@ -219,7 +220,7 @@ __vsyslog_internal (int pri, const char *fmt, va_list ap,
     vl = __vsnprintf_internal (pos, len, fmt, apc, mode_flags);
     va_end (apc);
 
-    if (vl < 0)
+    if (vl < 0 || vl >= INT_MAX - l)
       goto out;
 
     if (vl >= len)