aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArjun Shankar <arjun@redhat.com>2024-01-15 17:44:45 +0100
committerArjun Shankar <arjun@redhat.com>2024-01-30 15:56:17 +0100
commit2b58cba076e912961ceaa5fa58588e4b10f791c0 (patch)
treefb9c8e9af905d0c49d603cff0925b195d538ce82
parent67062eccd9a65d7fda9976a56aeaaf6c25a80214 (diff)
downloadglibc-2b58cba076e912961ceaa5fa58588e4b10f791c0.zip
glibc-2b58cba076e912961ceaa5fa58588e4b10f791c0.tar.gz
glibc-2b58cba076e912961ceaa5fa58588e4b10f791c0.tar.bz2
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. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com> (cherry picked from commit ddf542da94caf97ff43cc2875c88749880b7259b)
-rw-r--r--misc/syslog.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/misc/syslog.c b/misc/syslog.c
index 3108ae9..9336036 100644
--- a/misc/syslog.c
+++ b/misc/syslog.c
@@ -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)