From e3b60869416ef185060c5ec3ad3e03191dd23903 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 15 Jun 2022 18:09:50 +0200 Subject: [PATCH] fix data diff, where wrong length was used --- client/src/cmddata.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/client/src/cmddata.c b/client/src/cmddata.c index ad7879650..5653d78b8 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -3071,10 +3071,10 @@ static int CmdDiff(const char *Cmd) { // if ok, just print if (diff == 0) { - hex_to_buffer((uint8_t *)line, inA + i, width, width, 0, 1, true); + hex_to_buffer((uint8_t *)line, inA + i, width, sizeof(line), 0, 1, true); ascii_to_buffer((uint8_t *)(line + strlen(line)), inA + i, width, width, 0); - strcat(line + strlen(line), " | "); - hex_to_buffer((uint8_t *)(line + strlen(line)), inB + i, width, width, 0, 1, true); + strncat(line + strlen(line), " | ", 3); + hex_to_buffer((uint8_t *)(line + strlen(line)), inB + i, width, sizeof(line), 0, 1, true); ascii_to_buffer((uint8_t *)(line + strlen(line)), inB + i, width, width, 0); } else { @@ -3137,26 +3137,26 @@ static int CmdDiff(const char *Cmd) { memset(line, 0, sizeof(line)); if (tallestA) { - hex_to_buffer((uint8_t *)line, inA + i, width, width, 0, 1, true); - ascii_to_buffer((uint8_t *)(line + strlen(line)), inA + i, width, width, 0); + hex_to_buffer((uint8_t *)line, inA + i, width, sizeof(line), 0, 1, true); + ascii_to_buffer((uint8_t *)(line + strlen(line)), inA + i, width, sizeof(line), 0); strcat(line + strlen(line), " | "); for (int j = 0; j < width; j++) { - strcat(line + strlen(line), "-- "); + strncat(line + strlen(line), "-- ", 3); } for (int j = 0; j < width; j++) { - strcat(line + strlen(line), "."); + strncat(line + strlen(line), ".", 1); } } else { for (int j = 0; j < width; j++) { - strcat(line + strlen(line), "-- "); + strncat(line + strlen(line), "-- ", 3); } for (int j = 0; j < width; j++) { - strcat(line + strlen(line), "."); + strncat(line + strlen(line), ".", 1); } - strcat(line + strlen(line), " | "); - hex_to_buffer((uint8_t *)(line + strlen(line)), inB + i, width, width, 0, 1, true); - ascii_to_buffer((uint8_t *)(line + strlen(line)), inB + i, width, width, 0); + strncat(line + strlen(line), " | ", 3); + hex_to_buffer((uint8_t *)(line + strlen(line)), inB + i, width, sizeof(line), 0, 1, true); + ascii_to_buffer((uint8_t *)(line + strlen(line)), inB + i, width, sizeof(line), 0); } PrintAndLogEx(INFO, "%03X | %s", i, line);