fix PrintAndLogEx format string mismatches
Found by building with a printf format attribute on PrintAndLogEx. User visible: - hw version: GENERIC device/firmware name was passed as an unused arg and never printed - hf saflok selftest: PRIx32 lacked '%', printed a literal 'x' - hf mfp: key index value was never printed - hf waveshare: output filename was never printed Also: size_t/int64_t/uint64_t specifiers (%zu, PRId64, PRIX64), int macros printed with %zu, ' ' flag on %u, unused arg in flash_prepare, and non-literal strings passed as the format. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fb8a354249
commit
3deae3d904
15 files changed
+29
-29
No files matched your search
@@ -7960,7 +7960,7 @@ static int CmdHFiClassConfigCard(const char *Cmd) {
|
||||
if (ccidx > -1 && ccidx < ARRAYLEN(iclass_config_options)) {
|
||||
const iclass_config_card_item_t *item = get_config_card_item(ccidx);
|
||||
if (strlen(item->desc) == 0) {
|
||||
PrintAndLogEx(ERR, "out of range, %u (got %u)", ARRAYLEN(iclass_config_options), ccidx);
|
||||
PrintAndLogEx(ERR, "out of range, %zu (got %u)", ARRAYLEN(iclass_config_options), ccidx);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
if (strstr(item->desc, "ELITE") != NULL && got_kr == false) {
|
||||
|
||||
@@ -11288,7 +11288,7 @@ static int CmdHF14AMfValue(const char *Cmd) {
|
||||
optionsprovided++;
|
||||
action = 0;
|
||||
if ((incval <= 0) || (incval > 2147483647)) {
|
||||
PrintAndLogEx(WARNING, "increment value must be between 1 and 2147483647. Got %lli", incval);
|
||||
PrintAndLogEx(WARNING, "increment value must be between 1 and 2147483647. Got %" PRId64, incval);
|
||||
return PM3_EINVARG;
|
||||
} else
|
||||
value = (uint32_t)incval;
|
||||
@@ -11298,7 +11298,7 @@ static int CmdHF14AMfValue(const char *Cmd) {
|
||||
optionsprovided++;
|
||||
action = 1;
|
||||
if ((decval <= 0) || (decval > 2147483647)) {
|
||||
PrintAndLogEx(WARNING, "decrement value must be between 1 and 2147483647. Got %lli", decval);
|
||||
PrintAndLogEx(WARNING, "decrement value must be between 1 and 2147483647. Got %" PRId64, decval);
|
||||
return PM3_EINVARG;
|
||||
} else
|
||||
value = (uint32_t)decval;
|
||||
@@ -11308,7 +11308,7 @@ static int CmdHF14AMfValue(const char *Cmd) {
|
||||
optionsprovided++;
|
||||
action = 3;
|
||||
if ((setval < -2147483647) || (setval > 2147483647)) {
|
||||
PrintAndLogEx(WARNING, "set value must be between -2147483647 and 2147483647. Got %lli", setval);
|
||||
PrintAndLogEx(WARNING, "set value must be between -2147483647 and 2147483647. Got %" PRId64, setval);
|
||||
return PM3_EINVARG;
|
||||
} else
|
||||
value = (uint32_t)setval;
|
||||
|
||||
@@ -314,7 +314,7 @@ static int CLIGetUint32Hex(CLIParserContext *ctx, uint8_t paramnum, uint32_t def
|
||||
*valuePresent = (res == 1);
|
||||
|
||||
if (res == 2) {
|
||||
PrintAndLogEx(ERR, lengthErrorStr);
|
||||
PrintAndLogEx(ERR, "%s", lengthErrorStr);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
if (res == 0) {
|
||||
|
||||
@@ -1344,7 +1344,7 @@ static int CmdHFMFPChKey(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "--key index:", sprint_hex(keyn, 2));
|
||||
PrintAndLogEx(INFO, "--key index: %s", sprint_hex(keyn, 2));
|
||||
}
|
||||
|
||||
int res = MifareAuth4(&mf4session, keyn, key, false, true, true, true, verbose, false);
|
||||
@@ -1462,7 +1462,7 @@ static int CmdHFMFPChConf(const char *Cmd) {
|
||||
keyn[1] = usecck ? 0x01 : 0x00;
|
||||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "--key index:", sprint_hex(keyn, 2));
|
||||
PrintAndLogEx(INFO, "--key index: %s", sprint_hex(keyn, 2));
|
||||
}
|
||||
|
||||
int res = MifareAuth4(&mf4session, keyn, key, false, true, true, true, verbose, false);
|
||||
|
||||
@@ -2175,7 +2175,7 @@ static void fm11_print_key_hit_row(uint32_t nonce_count, uint8_t sec, uint8_t kt
|
||||
" Key sec " _YELLOW_("%03u") " key " _YELLOW_("%c") " = " _GREEN_("%012" PRIX64) " |"
|
||||
" " _YELLOW_("%25s") " | %13s ",
|
||||
(float)elapsed_key / 1000.0, nonce_count,
|
||||
fm11_real_sector(sec), kt ? 'B' : 'A', key & 0xFFFFFFFFFFFFULL,
|
||||
fm11_real_sector(sec), kt ? 'B' : 'A', (uint64_t)(key & 0xFFFFFFFFFFFFULL),
|
||||
kcount, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -1603,12 +1603,12 @@ static int CmdHFSaflokSelfTest(const char *Cmd) {
|
||||
uint32_t value_set = (uint32_t)iter;
|
||||
bool success = set_bitfield(&testdata, start_bit, num_bits, value_set);
|
||||
if (!success) {
|
||||
PrintAndLogEx(FAILED, "set_bitfield failed for start_bit %zu, num_bits %zu, test_value " PRIx32, start_bit, num_bits, value_set);
|
||||
PrintAndLogEx(FAILED, "set_bitfield failed for start_bit %zu, num_bits %zu, test_value %" PRIx32, start_bit, num_bits, value_set);
|
||||
result_bitfield = PM3_EFAILED;
|
||||
}
|
||||
uint32_t x = get_bitfield(&testdata, start_bit, num_bits);
|
||||
if (x != value_set) {
|
||||
PrintAndLogEx(FAILED, "get/set_bitfield failed for start_bit %zu, num_bits %zu, test_value " PRIx32 ": got " PRIx32", expected " PRIx32, start_bit, num_bits, value_set, x, value_set);
|
||||
PrintAndLogEx(FAILED, "get/set_bitfield failed for start_bit %zu, num_bits %zu, test_value %" PRIx32 ": got %" PRIx32", expected %" PRIx32, start_bit, num_bits, value_set, x, value_set);
|
||||
result_bitfield = PM3_EFAILED;
|
||||
}
|
||||
// Clear the field for the next test
|
||||
|
||||
@@ -665,7 +665,7 @@ static int CmdHF14AWSLoad(const char *Cmd) {
|
||||
gdImageDestroy(pal_img);
|
||||
return PM3_SUCCESS;
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Could not save converted image", outfile);
|
||||
PrintAndLogEx(WARNING, "Could not save converted image %s", outfile);
|
||||
gdImageDestroy(pal_img);
|
||||
return PM3_EFILE;
|
||||
}
|
||||
|
||||
+3
-3
@@ -2365,8 +2365,8 @@ void pm3_version(bool verbose, bool oneliner) {
|
||||
PrintAndLogEx(NORMAL, " Device.................... " _GREEN_("RDV4"));
|
||||
PrintAndLogEx(NORMAL, " Firmware.................. " _GREEN_("RDV4"));
|
||||
} else if (type == SIGN_GENERIC) {
|
||||
PrintAndLogEx(NORMAL, " Device.................... ", _GREEN_("GENERIC"));
|
||||
PrintAndLogEx(NORMAL, " Firmware.................. ", _GREEN_("GENERIC"));
|
||||
PrintAndLogEx(NORMAL, " Device.................... " _GREEN_("GENERIC"));
|
||||
PrintAndLogEx(NORMAL, " Firmware.................. " _GREEN_("GENERIC"));
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, " Device.................... " _RED_("Bad signature detected!"));
|
||||
PrintAndLogEx(NORMAL, " Firmware.................. " _YELLOW_("N/A"));
|
||||
@@ -2413,7 +2413,7 @@ void pm3_version(bool verbose, bool oneliner) {
|
||||
}
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(NORMAL, payload->versionstr);
|
||||
PrintAndLogEx(NORMAL, "%s", payload->versionstr);
|
||||
// PM5 doesn't report a built-in FPGA version (Gowin bitstream is loaded
|
||||
// externally), so skip the Xilinx FPGA_TYPE match check for it.
|
||||
if (!IfPm5() && strstr(payload->versionstr, FPGA_TYPE) == NULL) {
|
||||
|
||||
@@ -477,7 +477,7 @@ static int CmdLFHitagSRead(const char *Cmd) {
|
||||
break;
|
||||
}
|
||||
if (card->pages_reason[i] >= 0) {
|
||||
PrintAndLogEx(SUCCESS, "% 3u | %s | " NOLF, page_addr, sprint_hex_ascii(card->pages[i], HITAGS_PAGE_SIZE));
|
||||
PrintAndLogEx(SUCCESS, "%3u | %s | " NOLF, page_addr, sprint_hex_ascii(card->pages[i], HITAGS_PAGE_SIZE));
|
||||
|
||||
// access right
|
||||
if (page_addr == HITAGS_UID_PADR) {
|
||||
@@ -557,7 +557,7 @@ static int CmdLFHitagSRead(const char *Cmd) {
|
||||
} else
|
||||
PrintAndLogEx(NORMAL, "Data");
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "% 3u | -- -- -- -- | .... | N/A | " NOLF, page_addr);
|
||||
PrintAndLogEx(INFO, "%3u | -- -- -- -- | .... | N/A | " NOLF, page_addr);
|
||||
print_error(card->pages_reason[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ int read_htu_uid(void) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "UID....... " _GREEN_("%012llX"), uid);
|
||||
PrintAndLogEx(SUCCESS, "UID....... " _GREEN_("%012" PRIX64), uid);
|
||||
// PrintAndLogEx(SUCCESS, "TYPE...... " _GREEN_("%s"), htu_get_type_str(uid));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
@@ -456,7 +456,7 @@ static int CmdLFHitagURead(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (card->pages_reason[i] > 0) {
|
||||
PrintAndLogEx(SUCCESS, "% 3u | %s | " NOLF, page_addr, sprint_hex_ascii(card->pages[i], HITAGU_BLOCK_SIZE));
|
||||
PrintAndLogEx(SUCCESS, "%3u | %s | " NOLF, page_addr, sprint_hex_ascii(card->pages[i], HITAGU_BLOCK_SIZE));
|
||||
|
||||
// access right
|
||||
// 82xx
|
||||
@@ -508,7 +508,7 @@ static int CmdLFHitagURead(const char *Cmd) {
|
||||
PrintAndLogEx(NORMAL, "Data");
|
||||
}
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "% 3u | -- -- -- -- | .... | N/A | " NOLF, page_addr);
|
||||
PrintAndLogEx(INFO, "%3u | -- -- -- -- | .... | N/A | " NOLF, page_addr);
|
||||
print_error(card->pages_reason[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1017,7 +1017,7 @@ static void T55xx_Print_DownlinkMode(uint8_t downlink_mode) {
|
||||
break;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, msg);
|
||||
PrintAndLogEx(SUCCESS, "%s", msg);
|
||||
}
|
||||
|
||||
static int CmdT55xxWakeUp(const char *Cmd) {
|
||||
|
||||
@@ -2980,7 +2980,7 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
|
||||
);
|
||||
|
||||
if (*datalen > ISO15693_TAG_MAX_SIZE) {
|
||||
PrintAndLogEx(ERR, "loadFileJSONex: maxdatalen=%zu (%04zx) sptr=%zu (%04zx) -- exceeded maxdatalen"
|
||||
PrintAndLogEx(ERR, "loadFileJSONex: maxdatalen=%d (%04x) sptr=%zu (%04zx) -- exceeded maxdatalen"
|
||||
, ISO15693_TAG_MAX_SIZE
|
||||
, ISO15693_TAG_MAX_SIZE
|
||||
, *datalen
|
||||
@@ -2991,7 +2991,7 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
|
||||
}
|
||||
tag->pagesCount = *datalen / 4;
|
||||
if (tag->pagesCount > ISO15693_TAG_MAX_PAGES) {
|
||||
PrintAndLogEx(ERR, "loadFileJSONex: maxpagecount=%zu (%04zx) pagecount=%u (%04x) -- exceeded maxpagecount"
|
||||
PrintAndLogEx(ERR, "loadFileJSONex: maxpagecount=%d (%04x) pagecount=%u (%04x) -- exceeded maxpagecount"
|
||||
, ISO15693_TAG_MAX_PAGES
|
||||
, ISO15693_TAG_MAX_PAGES
|
||||
, tag->pagesCount
|
||||
@@ -3038,7 +3038,7 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
|
||||
|
||||
tag->pagesCount = sptr / 4;
|
||||
if (tag->pagesCount > ISO15693_TAG_MAX_PAGES) {
|
||||
PrintAndLogEx(ERR, "loadFileJSONex: maxpagecount=%zu (%04zx) pagecount=%u (%04x) -- exceeded maxpagecount"
|
||||
PrintAndLogEx(ERR, "loadFileJSONex: maxpagecount=%d (%04x) pagecount=%u (%04x) -- exceeded maxpagecount"
|
||||
, ISO15693_TAG_MAX_PAGES
|
||||
, ISO15693_TAG_MAX_PAGES
|
||||
, tag->pagesCount
|
||||
@@ -3085,7 +3085,7 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
|
||||
|
||||
tag->pagesCount = sptr / 8;
|
||||
if (tag->pagesCount > ISO15693_TAG_MAX_PAGES) {
|
||||
PrintAndLogEx(ERR, "loadFileJSONex: maxpagecount=%zu (%04zx) pagecount=%u (%04x) -- exceeded maxpagecount"
|
||||
PrintAndLogEx(ERR, "loadFileJSONex: maxpagecount=%d (%04x) pagecount=%u (%04x) -- exceeded maxpagecount"
|
||||
, ISO15693_TAG_MAX_PAGES
|
||||
, ISO15693_TAG_MAX_PAGES
|
||||
, tag->pagesCount
|
||||
|
||||
+1
-1
@@ -440,7 +440,7 @@ int flash_prepare(flash_file_t *ctx, int can_write_bl, flash_dev_t *flash_dev) {
|
||||
|
||||
// Check elf file is build for currently connected device?
|
||||
if (!CheckInformationMagicAndChipType(ctx->ver_info, flash_dev->chiptype)) {
|
||||
PrintAndLogEx(ERR, "The elf file is not applicable to the currently connected device.", flash_dev->chiptype);
|
||||
PrintAndLogEx(ERR, "The elf file is not applicable to the currently connected device.");
|
||||
res = PM3_EFILE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
+2
-2
@@ -568,11 +568,11 @@ buffer_savestate_t save_buffer8(uint8_t *src, size_t length) {
|
||||
// 1/4 of the size needed
|
||||
size_t buffSize = (length / 4);
|
||||
|
||||
PrintAndLogEx(DEBUG, "(save_buffer8) buffSize = %llu, length = %llu", buffSize, length);
|
||||
PrintAndLogEx(DEBUG, "(save_buffer8) buffSize = %zu, length = %zu", buffSize, length);
|
||||
|
||||
if (length % 4) {
|
||||
buffSize++;
|
||||
PrintAndLogEx(DEBUG, "(save_buffer8) new buffSize = %llu", buffSize);
|
||||
PrintAndLogEx(DEBUG, "(save_buffer8) new buffSize = %zu", buffSize);
|
||||
}
|
||||
|
||||
// calloc the memory needed
|
||||
|
||||
@@ -151,7 +151,7 @@ void printarr(const char *name, uint8_t *arr, int len) {
|
||||
snprintf(output + cx, outsize - cx, "};");
|
||||
}
|
||||
|
||||
PrintAndLogEx(INFO, output);
|
||||
PrintAndLogEx(INFO, "%s", output);
|
||||
free(output);
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ void printarr_human_readable(const char *title, uint8_t *arr, int len) {
|
||||
cx += snprintf(output + cx, outsize - cx, "%02x ", *(arr + i));
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(INFO, output);
|
||||
PrintAndLogEx(INFO, "%s", output);
|
||||
free(output);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user