#include <stdio.h>
#include <string.h>
+#include <inttypes.h>
+
#include "proxmark3.h"
#include "apps.h"
#include "util.h"
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);
}
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);
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));
case CborIntegerType: {
int64_t val;
cbor_value_get_int64(it, &val); // can't fail
- printf("%lld", (long long)val);
+ printf("%" PRIi64, val);
break;
}
case CborTagType: {
CborTag tag;
cbor_value_get_tag(it, &tag);
- printf("Tag(%lld)", (long long)tag);
+ printf("Tag(%" PRIu64, tag);
break;
}
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;
}
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]);
#include "util.h"
#include <stdint.h>
+#include <inttypes.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
}
if (strlen(buf) >= 2) {
- sscanf(buf, "%x", &temp);
+ sscanf(buf, "%" SCNx32, &temp);
data[*datalen] = (uint8_t)(temp & 0xff);
*buf = 0;
(*datalen)++;
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)
#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};
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");
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++) {