- correctly using stdtypes.h printf and scanf format string macros (PRIx64 et al)
- coverity fixes to client/cmdhfmf.c
- fix linker warning re missing entry point when linking fullimage.elf
$(OBJCOPY) -O elf32-littlearm -I binary -B arm --rename-section .data=compressed_data $^ $@
$(OBJDIR)/fullimage.elf: $(OBJDIR)/fullimage.nodata.o $(OBJDIR)/fullimage.data.o
- $(CC) $(LDFLAGS) -Wl,-T,ldscript,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^
+ $(CC) $(LDFLAGS) -Wl,-T,ldscript,-e,_osimage_entry,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^
tarbin: $(OBJS)
$(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(OBJS:%=armsrc/%) $(OBJS:%.s19=armsrc/%.elf)
// Unknown command
default:
- Dbprintf("Uknown command: %02x %02x",rx[0],rx[1]);
+ Dbprintf("Unknown command: %02x %02x",rx[0],rx[1]);
return;
break;
}
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS;
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
//Dbprintf("frame received: %d",frame_count);
- //DbpString("All done");
- cmd_send(CMD_ACK,bSuccessful,0,0,(byte_t*)tag.sectors,48);
+ //DbpString("All done");
+ cmd_send(CMD_ACK,bSuccessful,0,0,(byte_t*)tag.sectors,48);
}
SendCommand(&c);\r
\r
//flush queue\r
- while (ukbhit()) getchar();\r
-\r
+ while (ukbhit()) {\r
+ int c = getchar(); (void) c;\r
+ }\r
+ \r
// wait cycle\r
while (true) {\r
printf(".");\r
\r
// Read keys A from file\r
for (sectorNo=0; sectorNo<numSectors; sectorNo++) {\r
- if (fread( keyA[sectorNo], 1, 6, fin ) == 0) {\r
+ size_t bytes_read = fread(keyA[sectorNo], 1, 6, fin);\r
+ if (bytes_read != 6) {\r
PrintAndLog("File reading error.");\r
fclose(fin);\r
return 2;\r
\r
// Read keys B from file\r
for (sectorNo=0; sectorNo<numSectors; sectorNo++) {\r
- if (fread( keyB[sectorNo], 1, 6, fin ) == 0) {\r
+ size_t bytes_read = fread(keyB[sectorNo], 1, 6, fin);\r
+ if (bytes_read != 6) {\r
PrintAndLog("File reading error.");\r
fclose(fin);\r
return 2;\r
}\r
\r
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {\r
- if (fread(keyA[sectorNo], 1, 6, fkeys) == 0) {\r
+ size_t bytes_read = fread(keyA[sectorNo], 1, 6, fkeys);\r
+ if (bytes_read != 6) {\r
PrintAndLog("File reading error (dumpkeys.bin).");\r
-\r
fclose(fkeys);\r
return 2;\r
}\r
}\r
\r
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {\r
- if (fread(keyB[sectorNo], 1, 6, fkeys) == 0) {\r
+ size_t bytes_read = fread(keyB[sectorNo], 1, 6, fkeys);\r
+ if (bytes_read != 6) {\r
PrintAndLog("File reading error (dumpkeys.bin).");\r
fclose(fkeys);\r
return 2;\r
UsbCommand c = {CMD_MIFARE_WRITEBL, {FirstBlockOfSector(sectorNo) + blockNo, keyType, 0}};\r
memcpy(c.d.asBytes, key, 6);\r
\r
- if (fread(bldata, 1, 16, fdump) == 0) {\r
+ size_t bytes_read = fread(bldata, 1, 16, fdump);\r
+ if (bytes_read != 16) {\r
PrintAndLog("File reading error (dumpdata.bin).");\r
fclose(fdump);\r
return 2;\r
if (!p) {\r
PrintAndLog("Cannot allocate memory for defKeys");\r
free(keyBlock);\r
+ fclose(f);\r
return 2;\r
}\r
keyBlock = p;\r
\r
len = param_getstr(Cmd,nameParamNo,filename);\r
\r
- if (len > FILE_PATH_SIZE - 4) len = FILE_PATH_SIZE - 4;\r
+ if (len > FILE_PATH_SIZE - 5) len = FILE_PATH_SIZE - 5;\r
\r
fnameptr += len;\r
\r
\r
len = param_getstr(Cmd,nameParamNo,filename);\r
\r
- if (len > FILE_PATH_SIZE - 4) len = FILE_PATH_SIZE - 4;\r
+ if (len > FILE_PATH_SIZE - 5) len = FILE_PATH_SIZE - 5;\r
\r
// user supplied filename?\r
if (len < 1) {\r
return 0;\r
} else {\r
len = strlen(Cmd);\r
- if (len > FILE_PATH_SIZE - 4) len = FILE_PATH_SIZE - 4;\r
+ if (len > FILE_PATH_SIZE - 5) len = FILE_PATH_SIZE - 5;\r
\r
memcpy(filename, Cmd, len);\r
fnameptr += len;\r
\r
if (mfCSetBlock(blockNum, buf8, NULL, 0, flags)) {\r
PrintAndLog("Can't set magic card block: %d", blockNum);\r
+ fclose(f);\r
return 3;\r
}\r
blockNum++;\r
return 0;\r
} else {\r
len = strlen(Cmd);\r
- if (len > FILE_PATH_SIZE - 4) len = FILE_PATH_SIZE - 4;\r
+ if (len > FILE_PATH_SIZE - 5) len = FILE_PATH_SIZE - 5;\r
\r
if (len < 1) {\r
// get filename\r
uint16_t traceLen = resp.arg[1];\r
len = resp.arg[2];\r
\r
- if (res == 0) return 0; // we are done\r
+ if (res == 0) { // we are done\r
+ free(buf);\r
+ return 0;\r
+ }\r
\r
if (res == 1) { // there is (more) data to be transferred\r
if (pckNum == 0) { // first packet, (re)allocate necessary buffer\r
- if (traceLen > bufsize) {\r
+ if (traceLen > bufsize || buf == NULL) {\r
uint8_t *p;\r
if (buf == NULL) { // not yet allocated\r
p = malloc(traceLen);\r
UsbCommand c = {CMD_WRITE_TI_TYPE};
int res = 0;
- res = sscanf(Cmd, "%012" PRIx64 " %012" PRIx64 " %012" PRIx64 "", &c.arg[0], &c.arg[1], &c.arg[2]);
+ res = sscanf(Cmd, "%012" SCNx64 " %012" SCNx64 " %012" SCNx64 "", &c.arg[0], &c.arg[1], &c.arg[2]);
if (res == 2) c.arg[2]=0;
if (res < 2)
-#define __STDC_FORMAT_MACROS
#include <inttypes.h>
-#define llx PRIx64
-#define lli PRIi64
-
-// Test-file: test2.c
#include "crapto1.h"
#include <stdio.h>
#include <stdlib.h>
crypto1_word(t, uid ^ nt, 0);
crypto1_word(t, nr1_enc, 1);
if (ar1_enc == (crypto1_word(t, 0, 0) ^ prng_successor(nt, 64))) {
- printf("\nFound Key: [%012"llx"]\n\n",key);
+ printf("\nFound Key: [%012" PRIx64 "]\n\n",key);
break;
}
}
-#define __STDC_FORMAT_MACROS
#include <inttypes.h>
-#define llx PRIx64
-#define lli PRIi64
-
-// Test-file: test2.c
#include "crapto1.h"
#include <stdio.h>
#include <string.h>
lfsr_rollback_word(revstate, nr_enc, 1);
lfsr_rollback_word(revstate, uid ^ nt, 0);
crypto1_get_lfsr(revstate, &key);
- printf("\nFound Key: [%012"llx"]\n\n",key);
+ printf("\nFound Key: [%012" PRIx64"]\n\n",key);
crypto1_destroy(revstate);
return 0;
#include "crapto1.h"
-#define __STDC_FORMAT_MACROS
#include <inttypes.h>
-#define llx PRIx64
#include <stdio.h>
typedef unsigned char byte_t;
}
sscanf(argv[1],"%08x",&uid);
sscanf(argv[2],"%08x",&nt);
- sscanf(argv[3],"%016"llx,&par_info);
- sscanf(argv[4],"%016"llx,&ks_info);
+ sscanf(argv[3],"%016" SCNx64,&par_info);
+ sscanf(argv[4],"%016" SCNx64,&ks_info);
// Reset the last three significant bits of the reader nonce
nr &= 0xffffff1f;
- printf("\nuid(%08x) nt(%08x) par(%016"llx") ks(%016"llx")\n\n",uid,nt,par_info,ks_info);
+ printf("\nuid(%08x) nt(%08x) par(%016" PRIx64 ") ks(%016" PRIx64 ")\n\n",uid,nt,par_info,ks_info);
for (pos=0; pos<8; pos++)
{
state = lfsr_common_prefix(nr,rr,ks3x,par);
lfsr_rollback_word(state,uid^nt,0);
crypto1_get_lfsr(state,&key_recovered);
- printf("\nkey recovered: %012"llx"\n\n",key_recovered);
+ printf("\nkey recovered: %012" PRIx64 "\n\n",key_recovered);
crypto1_destroy(state);
return 0;