From 2d4db27539697020939b8ca4484f64bd99a7fe6d Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 6 Jul 2022 14:56:08 +0200 Subject: [PATCH] fix hex printing --- client/src/util.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/src/util.c b/client/src/util.c index 0565dc129..dab5fef58 100644 --- a/client/src/util.c +++ b/client/src/util.c @@ -278,14 +278,20 @@ static void print_buffer_ex(const uint8_t *data, const size_t len, int level, ui char buf[UTIL_BUFFER_SIZE_SPRINT + 3]; int i; for (i = 0; i < len; i += breaks) { + + memset(buf, 0x00, sizeof(buf)); + if (len - i < breaks) { // incomplete block, will be treated out of the loop break; } + // (16 * 3) + (16) + + 1 snprintf(buf, sizeof(buf), "%*s%02x: ", (level * 4), " ", i); hex_to_buffer((uint8_t *)(buf + strlen(buf)), data + i, breaks, (sizeof(buf) - strlen(buf) - 1), 0, 1, true); + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "| %s", sprint_ascii(data + i, breaks)); + PrintAndLogEx(INFO, "%s", buf); }