From 375b1439a13c85448de2f87c2dc9943cad242171 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 19 Oct 2024 06:46:16 +0200 Subject: [PATCH] data num now also properly pad hex converted to binary string operations 02 -> 00000010 -> 11111101 -> 01000000 --- client/src/cmddata.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/client/src/cmddata.c b/client/src/cmddata.c index 20e4cfe71..35573b88a 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -3164,9 +3164,11 @@ static int CmdNumCon(const char *Cmd) { // only pad bin string int pn = 0; - if (i==2) { - if (slen < blen) { + if (i == 2) { + if (blen && slen < blen) { pn = blen - slen + 1; + } else if (hlen && (slen < (hlen * 4))) { + pn = (hlen * 4) - slen + 1; } } PrintAndLogEx(SUCCESS, "%s%.*s%s",radix[i].desc, pn, pad, s); @@ -3197,9 +3199,11 @@ static int CmdNumCon(const char *Cmd) { char scpy[600] = {0x30}; memset(scpy, 0x30, sizeof(scpy)); int pn = 0; - if (i==2) { - if (slen < blen) { + if (i == 2) { + if (blen && slen < blen) { pn = blen - slen + 1; + } else if (hlen && (slen < (hlen * 4))) { + pn = (hlen * 4) - slen + 1; } } memcpy(scpy + pn, s, slen); @@ -3246,9 +3250,12 @@ static int CmdNumCon(const char *Cmd) { char scpy[600] = {0x30}; memset(scpy, 0x30, sizeof(scpy)); int pn = 0; - if (slen < blen) { + if (blen && slen < blen) { pn = blen - slen + 1; + } else if (hlen && (slen < (hlen * 4))) { + pn = (hlen * 4) - slen + 1; } + memcpy(scpy + pn, s, slen); str_inverse_bin(scpy, strlen(scpy)); PrintAndLogEx(SUCCESS, "%s%s", radix[i].desc, scpy); -- 2.11.4.GIT