Skip to content

Commit

Permalink
data num now also properly pad hex converted to binary string operati…
Browse files Browse the repository at this point in the history
…ons 02 -> 00000010 -> 11111101 -> 01000000
  • Loading branch information
iceman1001 committed Oct 19, 2024
1 parent 8c04d9d commit 375b143
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions client/src/cmddata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 375b143

Please sign in to comment.