From 58902e342f6d53d6783c99fe79a03168d46cd56f Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 8 Jun 2025 15:49:52 -0500 Subject: [PATCH] Zero output parameters when BbGet*() fails --- src/ByteBuffer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ByteBuffer.c b/src/ByteBuffer.c index aa1b0b8..79e172b 100644 --- a/src/ByteBuffer.c +++ b/src/ByteBuffer.c @@ -55,6 +55,7 @@ void BbRewindBuffer(PBYTE_BUFFER buff) { // Get a variable number of bytes from the byte buffer (all or nothing though) bool BbGetBytes(PBYTE_BUFFER buff, uint8_t* data, int length) { if (buff->position + length > buff->length) { + memset(data, 0, length); return false; } @@ -72,6 +73,7 @@ bool BbGet8(PBYTE_BUFFER buff, uint8_t* c) { // Get a short from the byte buffer bool BbGet16(PBYTE_BUFFER buff, uint16_t* s) { if (buff->position + sizeof(*s) > buff->length) { + *s = 0; return false; } @@ -86,6 +88,7 @@ bool BbGet16(PBYTE_BUFFER buff, uint16_t* s) { // Get an int from the byte buffer bool BbGet32(PBYTE_BUFFER buff, uint32_t* i) { if (buff->position + sizeof(*i) > buff->length) { + *i = 0; return false; } @@ -100,6 +103,7 @@ bool BbGet32(PBYTE_BUFFER buff, uint32_t* i) { // Get a long from the byte buffer bool BbGet64(PBYTE_BUFFER buff, uint64_t* l) { if (buff->position + sizeof(*l) > buff->length) { + *l = 0; return false; }