local-CVE-2023-6780
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Tue, 23 Jan 2024 20:57:06 +0000 (21:57 +0100)
committerAurelien Jarno <aurel32@debian.org>
Tue, 23 Jan 2024 20:57:06 +0000 (21:57 +0100)
syslog: Fix integer overflow in __vsyslog_internal (CVE-2023-6780)

__vsyslog_internal calculated a buffer size by adding two integers, but
did not first check if the addition would overflow.  This commit fixes
that.

Gbp-Pq: Topic any
Gbp-Pq: Name local-CVE-2023-6780.patch

misc/syslog.c

index 3108ae913477a0fb99dfa88fb32f6d89aca21fae..9336036666aada3d65b7fdca4e5b68b275e2f3b7 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 */
@@ -217,7 +218,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)