From 66fb589680db241e916b7f7f43d9e6058dcdb571 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 3 Jun 2013 04:32:12 +0200 Subject: [PATCH] debug.h: Handle overflow in debug(). --- src/debug.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/debug.h b/src/debug.h index 6456898..4dab03c 100644 --- a/src/debug.h +++ b/src/debug.h @@ -33,6 +33,10 @@ static void debug(const char *format, ...) { va_start(ap, format); int written = vsnprintf(buffer, sizeof(buffer), format, ap); va_end(ap); + /* Overflow. */ + if ((size_t)written >= sizeof(buffer)) { + written = sizeof(buffer) - 1; + } /* Make sure these functions are loaded. */ DLSYM_FUNCTION(real_write, "write"); -- 2.45.2