From fcc50f4da687f371a4e500d72d9e1ef9cc2926e3 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 26 Oct 2007 18:03:28 -0600 Subject: [PATCH] abort if vsnprintf() overflows in makeByteArray --- src/machine.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/machine.cpp b/src/machine.cpp index 63f6233d82..af83697c7a 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -376,10 +376,11 @@ postCollect(Thread* t) object makeByteArray(Thread* t, const char* format, va_list a) { - static const unsigned Size = 256; + const int Size = 256; char buffer[Size]; - vsnprintf(buffer, Size - 1, format, a); + int r = vsnprintf(buffer, Size - 1, format, a); + expect(t, r >= 0 and r < Size - 1); object s = makeByteArray(t, strlen(buffer) + 1, false); memcpy(&byteArrayBody(t, s, 0), buffer, byteArrayLength(t, s));