mirror of
https://github.com/corda/corda.git
synced 2025-01-08 14:03:06 +00:00
abort if vsnprintf() overflows in makeByteArray
This commit is contained in:
parent
46ac6f92ee
commit
fcc50f4da6
@ -376,10 +376,11 @@ postCollect(Thread* t)
|
|||||||
object
|
object
|
||||||
makeByteArray(Thread* t, const char* format, va_list a)
|
makeByteArray(Thread* t, const char* format, va_list a)
|
||||||
{
|
{
|
||||||
static const unsigned Size = 256;
|
const int Size = 256;
|
||||||
char buffer[Size];
|
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);
|
object s = makeByteArray(t, strlen(buffer) + 1, false);
|
||||||
memcpy(&byteArrayBody(t, s, 0), buffer, byteArrayLength(t, s));
|
memcpy(&byteArrayBody(t, s, 0), buffer, byteArrayLength(t, s));
|
||||||
|
Loading…
Reference in New Issue
Block a user