From 7fc4fcc926ec2be9c762e44c49ef41fa7739b2e4 Mon Sep 17 00:00:00 2001 From: Trond Norbye Date: Mon, 22 Feb 2010 22:09:28 +0100 Subject: [PATCH] Fix potential buffer overflow in vperror --- util.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util.c b/util.c index f935facac6..cc2da65154 100644 --- a/util.c +++ b/util.c @@ -92,11 +92,13 @@ bool safe_strtol(const char *str, int32_t *out) { void vperror(const char *fmt, ...) { int old_errno = errno; - char buf[80]; + char buf[1024]; va_list ap; va_start(ap, fmt); - vsnprintf(buf, sizeof(buf), fmt, ap); + if (vsnprintf(buf, sizeof(buf), fmt, ap) == -1) { + buf[sizeof(buf) - 1] = '\0'; + } va_end(ap); errno = old_errno;