From 415dd84a8d6ddf752224bd12803f48ebf0544ced Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sat, 19 Dec 2020 19:32:06 +0100 Subject: [PATCH] fix print_buffer out-of-boundaries bug --- client/src/util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/util.c b/client/src/util.c index 4ba4af108..1dad2cd4b 100644 --- a/client/src/util.c +++ b/client/src/util.c @@ -208,7 +208,9 @@ void print_buffer(const uint8_t *data, const size_t len, int level) { char buf[UTIL_BUFFER_SIZE_SPRINT + 3]; int i; for (i = 0; i < len; i += 16) { - + if (len - i < 16) { // incomplete block, will be treated out of the loop + break; + } // (16 * 3) + (16) + + 1 memset(buf, 0, sizeof(buf)); sprintf(buf, "%*s%02x: ", (level * 4), " ", i);