mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
Move all integer printing to use PRI* macros
Hopefully will make CodeQL happy this time.
This commit is contained in:
parent
b02c6ece26
commit
a0214f12d4
1 changed files with 16 additions and 16 deletions
|
@ -333,12 +333,12 @@ static void piv_tag_dump_enum(const struct tlv *tlv, const struct piv_tag *tag,
|
||||||
const struct piv_tag_enum *values = tag->data;
|
const struct piv_tag_enum *values = tag->data;
|
||||||
for (size_t i = 0; values[i].name != NULL; i++) {
|
for (size_t i = 0; values[i].name != NULL; i++) {
|
||||||
if (values[i].value == tlv->value[0]) {
|
if (values[i].value == tlv->value[0]) {
|
||||||
PrintAndLogEx(NORMAL, " %u - '" _YELLOW_("%s")"'",
|
PrintAndLogEx(NORMAL, " %" PRIu8 " - '" _YELLOW_("%s")"'",
|
||||||
tlv->value[0], values[i].name);
|
tlv->value[0], values[i].name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrintAndLogEx(NORMAL, " %u - " _RED_("Unknown??"), tlv->value[0]);
|
PrintAndLogEx(NORMAL, " %" PRIu8 " - " _RED_("Unknown??"), tlv->value[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void piv_tag_dump_tlv(const struct tlv *tlv, const struct piv_tag *tag, int level) {
|
static void piv_tag_dump_tlv(const struct tlv *tlv, const struct piv_tag *tag, int level) {
|
||||||
|
@ -383,16 +383,16 @@ static void piv_tag_dump_int_array(const struct tlv *tlv, const struct piv_tag *
|
||||||
}
|
}
|
||||||
sub_tlv.value = buf;
|
sub_tlv.value = buf;
|
||||||
if (index < max_labels) {
|
if (index < max_labels) {
|
||||||
PrintAndLogEx(INFO, "%*s--%2x[%02zx] '%s':" NOLF, (level * 4), " ", sub_tlv.tag, sub_tlv.len, labels[index]);
|
PrintAndLogEx(INFO, "%*s--%2" PRIx32 "[%02z" PRIx32 "] '%s':" NOLF, (level * 4), " ", sub_tlv.tag, sub_tlv.len, labels[index]);
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO, "%*s--%2x[%02zx] 'Unknown item index %d':" NOLF, (level * 4), " ", sub_tlv.tag, sub_tlv.len, index);
|
PrintAndLogEx(INFO, "%*s--%2" PRIx32 "[%02z" PRIx32 "] 'Unknown item index %" PRId32 "':" NOLF, (level * 4), " ", sub_tlv.tag, sub_tlv.len, index);
|
||||||
}
|
}
|
||||||
if (sub_tlv.len <= sizeof(v)) {
|
if (sub_tlv.len <= sizeof(v)) {
|
||||||
// We have enough space to convert to integer
|
// We have enough space to convert to integer
|
||||||
for (int i = 0; i < sub_tlv.len; i++) {
|
for (int i = 0; i < sub_tlv.len; i++) {
|
||||||
v = (v << 8) + sub_tlv.value[i];
|
v = (v << 8) + sub_tlv.value[i];
|
||||||
}
|
}
|
||||||
PrintAndLogEx(NORMAL, _YELLOW_("%u") " bytes (" _YELLOW_("%zx") ")", v, v);
|
PrintAndLogEx(NORMAL, _YELLOW_("%" PRIu32) " bytes (" _YELLOW_("%" PRIx32) ")", v, v);
|
||||||
} else {
|
} else {
|
||||||
// Number is to big. Just print hex value
|
// Number is to big. Just print hex value
|
||||||
PrintAndLogEx(NORMAL, _YELLOW_("0x%s"), sprint_hex_inrow(sub_tlv.value, sub_tlv.len));
|
PrintAndLogEx(NORMAL, _YELLOW_("0x%s"), sprint_hex_inrow(sub_tlv.value, sub_tlv.len));
|
||||||
|
@ -466,7 +466,7 @@ static void piv_print_fascn(const uint8_t *buf, const size_t len, int level) {
|
||||||
PrintAndLogEx(NORMAL, "%s" NOLF, encoded[tmp & 0x1f]);
|
PrintAndLogEx(NORMAL, "%s" NOLF, encoded[tmp & 0x1f]);
|
||||||
}
|
}
|
||||||
uint8_t lrc = buf[24] & 0x1f;
|
uint8_t lrc = buf[24] & 0x1f;
|
||||||
PrintAndLogEx(NORMAL, " LRC=[" _YELLOW_("%02x") "]", lrc);
|
PrintAndLogEx(NORMAL, " LRC=[" _YELLOW_("%02" PRIx8 ) "]", lrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool piv_tag_dump(const struct tlv *tlv, int level) {
|
static bool piv_tag_dump(const struct tlv *tlv, int level) {
|
||||||
|
@ -477,7 +477,7 @@ static bool piv_tag_dump(const struct tlv *tlv, int level) {
|
||||||
|
|
||||||
const struct piv_tag *tag = piv_get_tag(tlv);
|
const struct piv_tag *tag = piv_get_tag(tlv);
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "%*s--%2x[%02zx] '%s':" NOLF, (level * 4), " ", tlv->tag, tlv->len, tag->name);
|
PrintAndLogEx(INFO, "%*s--%2" PRIu32 "[%02z" PRIx32 "] '%s':" NOLF, (level * 4), " ", tlv->tag, tlv->len, tag->name);
|
||||||
|
|
||||||
switch (tag->type) {
|
switch (tag->type) {
|
||||||
case PIV_TAG_GENERIC:
|
case PIV_TAG_GENERIC:
|
||||||
|
@ -491,7 +491,7 @@ static bool piv_tag_dump(const struct tlv *tlv, int level) {
|
||||||
PrintAndLogEx(NORMAL, " '" _YELLOW_("%s")"'", sprint_hex_inrow(tlv->value, tlv->len));
|
PrintAndLogEx(NORMAL, " '" _YELLOW_("%s")"'", sprint_hex_inrow(tlv->value, tlv->len));
|
||||||
break;
|
break;
|
||||||
case PIV_TAG_NUMERIC:
|
case PIV_TAG_NUMERIC:
|
||||||
PrintAndLogEx(NORMAL, " " _YELLOW_("%lu"), piv_value_numeric(tlv, 0, tlv->len * 2));
|
PrintAndLogEx(NORMAL, " " _YELLOW_("%" PRIu32), piv_value_numeric(tlv, 0, tlv->len * 2));
|
||||||
break;
|
break;
|
||||||
case PIV_TAG_YYYYMMDD:
|
case PIV_TAG_YYYYMMDD:
|
||||||
piv_tag_dump_yyyymmdd(tlv, tag, level);
|
piv_tag_dump_yyyymmdd(tlv, tag, level);
|
||||||
|
@ -516,9 +516,9 @@ static bool piv_tag_dump(const struct tlv *tlv, int level) {
|
||||||
} else {
|
} else {
|
||||||
struct guid guid = {0};
|
struct guid guid = {0};
|
||||||
parse_guid(tlv->value, &guid);
|
parse_guid(tlv->value, &guid);
|
||||||
PrintAndLogEx(NORMAL, " " _YELLOW_("{%08x-%04x-%04x-") NOLF, guid.part1, guid.part2, guid.part3);
|
PrintAndLogEx(NORMAL, " " _YELLOW_("{%08" PRIx32 "-%04" PRIx16 "-%04" PRIx16 "-") NOLF, guid.part1, guid.part2, guid.part3);
|
||||||
for (size_t i = 0; i < 8; i++) {
|
for (size_t i = 0; i < 8; i++) {
|
||||||
PrintAndLogEx(NORMAL, _YELLOW_("%02x") NOLF, guid.data[i]);
|
PrintAndLogEx(NORMAL, _YELLOW_("%02" PRIx8) NOLF, guid.data[i]);
|
||||||
}
|
}
|
||||||
PrintAndLogEx(NORMAL, _YELLOW_("}"));
|
PrintAndLogEx(NORMAL, _YELLOW_("}"));
|
||||||
}
|
}
|
||||||
|
@ -681,7 +681,7 @@ static int PivGetDataByCidAndPrint(Iso7816CommandChannel channel, const struct p
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (verbose == true) {
|
if (verbose == true) {
|
||||||
PrintAndLogEx(INFO, "APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
PrintAndLogEx(INFO, "APDU response status: %04" PRIx16 " - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -709,7 +709,7 @@ static int PivAuthenticateSign(Iso7816CommandChannel channel, uint8_t alg_id, ui
|
||||||
const size_t MAX_NONCE_LEN = 0x7a;
|
const size_t MAX_NONCE_LEN = 0x7a;
|
||||||
if (nonce_len > MAX_NONCE_LEN) {
|
if (nonce_len > MAX_NONCE_LEN) {
|
||||||
if (verbose == true) {
|
if (verbose == true) {
|
||||||
PrintAndLogEx(WARNING, "Nonce cannot exceed %zu bytes. Got %zu bytes.", MAX_NONCE_LEN, nonce_len);
|
PrintAndLogEx(WARNING, "Nonce cannot exceed %" PRIi32 " bytes. Got %" PRIi32 " bytes.", MAX_NONCE_LEN, nonce_len);
|
||||||
}
|
}
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
@ -725,12 +725,12 @@ static int PivAuthenticateSign(Iso7816CommandChannel channel, uint8_t alg_id, ui
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
int res = Iso7816ExchangeEx(channel, false, true, apdu, false, 0, buf, APDU_RES_LEN, &len, &sw);
|
int res = Iso7816ExchangeEx(channel, false, true, apdu, false, 0, buf, APDU_RES_LEN, &len, &sw);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(FAILED, "Sending APDU failed with code %d", res);
|
PrintAndLogEx(FAILED, "Sending APDU failed with code %" PRId32, res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
if (sw != ISO7816_OK) {
|
if (sw != ISO7816_OK) {
|
||||||
if (verbose == true) {
|
if (verbose == true) {
|
||||||
PrintAndLogEx(INFO, "Unexpected APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
PrintAndLogEx(INFO, "Unexpected APDU response status: %04" PRIx16 " - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||||
}
|
}
|
||||||
return PM3_EFAILED;
|
return PM3_EFAILED;
|
||||||
}
|
}
|
||||||
|
@ -751,7 +751,7 @@ static int PivSelect(Iso7816CommandChannel channel, bool activateField, bool lea
|
||||||
|
|
||||||
int res = Iso7816Select(channel, activateField, leaveFieldOn, applet, appletLen, buf, sizeof(buf), &len, &sw);
|
int res = Iso7816Select(channel, activateField, leaveFieldOn, applet, appletLen, buf, sizeof(buf), &len, &sw);
|
||||||
if ((sw != 0) && (silent == false)) {
|
if ((sw != 0) && (silent == false)) {
|
||||||
PrintAndLogEx(INFO, "APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
PrintAndLogEx(INFO, "APDU response status: %04" PRIx16 " - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != PM3_SUCCESS || sw != ISO7816_OK) {
|
if (res != PM3_SUCCESS || sw != ISO7816_OK) {
|
||||||
|
@ -858,7 +858,7 @@ static int CmdPIVGetData(const char *Cmd) {
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
if ((tag_len < 1) || (tag_len > 3)) {
|
if ((tag_len < 1) || (tag_len > 3)) {
|
||||||
PrintAndLogEx(WARNING, "Tag should be between 1 and 3 bytes. Got %i", tag_len);
|
PrintAndLogEx(WARNING, "Tag should be between 1 and 3 bytes. Got %" PRIi32, tag_len);
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue