Fix some printf/scanf format strings

This commit is contained in:
pwpiwi 2020-05-11 14:46:22 +02:00
parent ebf1404a81
commit 98a67bc908
10 changed files with 29 additions and 32 deletions

View file

@ -14,6 +14,8 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include "proxmark3.h"
#include "apps.h"
#include "util.h"
@ -192,7 +194,7 @@ void iso14a_set_trigger(bool enable) {
void iso14a_set_timeout(uint32_t timeout) {
// adjust timeout by FPGA delays and 2 additional ssp_frames to detect SOF
iso14a_timeout = timeout + (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER)/(16*8) + 2;
if(MF_DBGLEVEL >= 3) Dbprintf("ISO14443A Timeout set to %ld (%dms)", timeout, timeout / 106);
if (MF_DBGLEVEL >= 3) Dbprintf("ISO14443A Timeout set to %" PRIu32 " (%dms)", timeout, timeout / 106);
}

View file

@ -335,10 +335,10 @@ int CmdFPGAOff(const char *Cmd)
int CmdLCD(const char *Cmd)
{
int i, j;
unsigned int i, j;
UsbCommand c={CMD_LCD};
sscanf(Cmd, "%x %d", &i, &j);
sscanf(Cmd, "%x %u", &i, &j);
while (j--) {
c.arg[0] = i & 0x1ff;
SendCommand(&c);

View file

@ -400,7 +400,7 @@ static void emv_tag_dump_numeric(const struct tlv *tlv, const struct emv_tag *ta
static void emv_tag_dump_yymmdd(const struct tlv *tlv, const struct emv_tag *tag, FILE *f, int level)
{
PRINT_INDENT(level);
fprintf(f, "\tDate: 20%02ld.%ld.%ld\n",
fprintf(f, "\tDate: 20%02lu.%lu.%lu\n",
emv_value_numeric(tlv, 0, 2),
emv_value_numeric(tlv, 2, 4),
emv_value_numeric(tlv, 4, 6));

View file

@ -40,7 +40,7 @@ static CborError dumpelm(CborValue *it, bool *got_next, int nestingLevel) {
case CborIntegerType: {
int64_t val;
cbor_value_get_int64(it, &val); // can't fail
printf("%lld", (long long)val);
printf("%" PRIi64, val);
break;
}
@ -71,7 +71,7 @@ static CborError dumpelm(CborValue *it, bool *got_next, int nestingLevel) {
case CborTagType: {
CborTag tag;
cbor_value_get_tag(it, &tag);
printf("Tag(%lld)", (long long)tag);
printf("Tag(%" PRIu64, tag);
break;
}
@ -206,13 +206,7 @@ int TinyCborPrintFIDOPackage(uint8_t cmdCode, bool isResponse, uint8_t *data, si
CborError err = dumprecursive(cmdCode, isResponse, &cb, false, 0);
if (err) {
fprintf(stderr,
#if __WORDSIZE == 64
"CBOR parsing failure at offset %" PRId64 " : %s\n",
#else
"CBOR parsing failure at offset %" PRId32 " : %s\n",
#endif
cb.ptr - data, cbor_error_string(err));
fprintf(stderr, "CBOR parsing failure at offset %td : %s\n", cb.ptr - data, cbor_error_string(err));
return 1;
}

View file

@ -99,9 +99,9 @@ int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, bool hardn
if (i >= num_infiles * (hardnested_mode?HARDNESTED_TABLE_SIZE:FPGA_CONFIG_SIZE)) {
if (hardnested_mode) {
fprintf(stderr, "Input file too big (> %lu bytes). This is probably not a hardnested bitflip state table.\n", HARDNESTED_TABLE_SIZE);
fprintf(stderr, "Input file too big (> %zu bytes). This is probably not a hardnested bitflip state table.\n", HARDNESTED_TABLE_SIZE);
} else {
fprintf(stderr, "Input files too big (total > %lu bytes). These are probably not PM3 FPGA config files.\n", num_infiles*FPGA_CONFIG_SIZE);
fprintf(stderr, "Input files too big (total > %zu bytes). These are probably not PM3 FPGA config files.\n", num_infiles*FPGA_CONFIG_SIZE);
}
for(uint16_t j = 0; j < num_infiles; j++) {
fclose(infile[j]);

View file

@ -11,6 +11,7 @@
#include "util.h"
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
@ -572,7 +573,7 @@ int param_gethex_to_eol(const char *line, int paramnum, uint8_t * data, int maxd
}
if (strlen(buf) >= 2) {
sscanf(buf, "%x", &temp);
sscanf(buf, "%" SCNx32, &temp);
data[*datalen] = (uint8_t)(temp & 0xff);
*buf = 0;
(*datalen)++;

View file

@ -261,7 +261,7 @@ int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
if (!fgets(buffer, sizeof(buffer), maps))
break;
if (sscanf(buffer, "%" SCNx64 "-%" SCNx64 " %s %" SCNx64 " %x:%x %u %s\n", &low, &high, perms, &offset, &major, &minor, &inode, path) == 8)
if (sscanf(buffer, "%" SCNx64 "-%" SCNx64 " %s %" SCNx64 " %" SCNx32 ":%" SCNx32 " %" SCNu32 " %s\n", &low, &high, perms, &offset, &major, &minor, &inode, path) == 8)
{
uint64_t addr = (uint64_t)(uintptr_t)WAI_RETURN_ADDRESS();
if (low <= addr && addr <= high)

View file

@ -9,7 +9,7 @@
#define FPGA_BITSTREAM_FIXED_HEADER_SIZE sizeof(bitparse_fixed_header)
#define FPGA_INTERLEAVE_SIZE 288
#define FPGA_CONFIG_SIZE 42336L // our current fpga_[lh]f.bit files are 42175 bytes. Rounded up to next multiple of FPGA_INTERLEAVE_SIZE
#define FPGA_CONFIG_SIZE ((size_t)42336) // our current fpga_[lh]f.bit files are 42175 bytes. Rounded up to next multiple of FPGA_INTERLEAVE_SIZE
#define FPGA_TRACE_SIZE 3072
static const uint8_t bitparse_fixed_header[] = {0x00, 0x09, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x00, 0x00, 0x01};

View file

@ -25,18 +25,18 @@ int main (int argc, char *argv[]) {
bool moebius_attack = (argc == 8);
sscanf(argv[1],"%x",&data.cuid);
sscanf(argv[2],"%x",&data.nonce);
sscanf(argv[1],"%" SCNx32, &data.cuid);
sscanf(argv[2],"%" SCNx32, &data.nonce);
data.nonce2 = data.nonce;
sscanf(argv[3],"%x",&data.nr);
sscanf(argv[4],"%x",&data.ar);
sscanf(argv[3],"%" SCNx32, &data.nr);
sscanf(argv[4],"%" SCNx32, &data.ar);
if (moebius_attack) {
sscanf(argv[5],"%x",&data.nonce2);
sscanf(argv[6],"%x",&data.nr2);
sscanf(argv[7],"%x",&data.ar2);
sscanf(argv[5],"%" SCNx32, &data.nonce2);
sscanf(argv[6],"%" SCNx32, &data.nr2);
sscanf(argv[7],"%" SCNx32, &data.ar2);
} else {
sscanf(argv[5],"%x",&data.nr2);
sscanf(argv[6],"%x",&data.ar2);
sscanf(argv[5],"%" SCNx32, &data.nr2);
sscanf(argv[6],"%" SCNx32, &data.ar2);
}
printf("Recovering key for:\n");

View file

@ -28,11 +28,11 @@ int main (int argc, char *argv[])
int enclen[encc];
uint8_t enc[encc][120];
sscanf(argv[1], "%x", &uid);
sscanf(argv[2], "%x", &nt);
sscanf(argv[3], "%x", &nr_enc);
sscanf(argv[4], "%x", &ar_enc);
sscanf(argv[5], "%x", &at_enc);
sscanf(argv[1], "%" SCNx32, &uid);
sscanf(argv[2], "%" SCNx32, &nt);
sscanf(argv[3], "%" SCNx32, &nr_enc);
sscanf(argv[4], "%" SCNx32, &ar_enc);
sscanf(argv[5], "%" SCNx32, &at_enc);
for (int i = 0; i < encc; i++) {
enclen[i] = strlen(argv[i + 6]) / 2;
for (int i2 = 0; i2 < enclen[i]; i2++) {