// else we have to create a share memory
int i;
fseek(f,startblock*8,SEEK_SET);
- if ( fread(tag_data,sizeof(iclass_block_t),endblock - startblock + 1,f) == 0){
+ size_t bytes_read = fread(tag_data,sizeof(iclass_block_t),endblock - startblock + 1,f);
+ if ( bytes_read == 0){
PrintAndLog("File reading error.");
fclose(f);
return 2;
}\r
\r
// Read keys A from file\r
+ size_t bytes_read;\r
for (sectorNo=0; sectorNo<numSectors; sectorNo++) {\r
- if (fread( keyA[sectorNo], 1, 6, fin ) == 0) {\r
+ bytes_read = fread( keyA[sectorNo], 1, 6, fin );\r
+ if ( bytes_read == 0) {\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
+ bytes_read = fread( keyB[sectorNo], 1, 6, fin );\r
+ if ( bytes_read == 0) {\r
PrintAndLog("File reading error.");\r
fclose(fin);\r
return 2;\r
return 1;\r
}\r
\r
+ size_t bytes_read;\r
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {\r
- if (fread(keyA[sectorNo], 1, 6, fkeys) == 0) {\r
+ bytes_read = fread( keyA[sectorNo], 1, 6, fkeys );\r
+ if ( bytes_read == 0) {\r
PrintAndLog("File reading error (dumpkeys.bin).");\r
fclose(fkeys);\r
return 2;\r
}\r
\r
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {\r
- if (fread(keyB[sectorNo], 1, 6, fkeys) == 0) {\r
+ bytes_read = fread( keyB[sectorNo], 1, 6, fkeys );\r
+ if ( bytes_read == 0) {\r
PrintAndLog("File reading error (dumpkeys.bin).");\r
fclose(fkeys);\r
return 2;\r
}
PrintAndLog("Reading nonces from file nonces.bin...");
- if (fread(read_buf, 1, 6, fnonces) == 0) {
+ size_t bytes_read = fread(read_buf, 1, 6, fnonces);
+ if ( bytes_read == 0) {
PrintAndLog("File reading error.");
fclose(fnonces);
return 1;
return 1;
}
tag_mem_supplied = true;
- if (fread(c.d.asBytes,48,1,pf) == 0) {
+ size_t bytes_read = fread(c.d.asBytes, 48, 1, pf);
+ if ( bytes_read == 0) {
PrintAndLog("Error: File reading error");
fclose(pf);
return 1;
FILE *f;
int retval = 1;
f = fopen("iclass_key.bin", "rb");
- if (f)
- {
- if(fread(key, sizeof(uint8_t), 8, f) == 1)
- {
- retval = 0;
- }
- fclose(f);
+ if (!f) {
+ return 0;
+ }
+
+ size_t bytes_read = fread(key, sizeof(uint8_t), 8, f);
+ if ( bytes_read == 1) {
+ retval = 0;
}
+ fclose(f);
return retval;
}
prnlog("[+] Checking if the master key is present (iclass_key.bin)...");
uint8_t key[8] = {0};
- if(readKeyFile(key))
- {
+ if(readKeyFile(key)) {
prnlog("[+] Master key not present, will not be able to do all testcases");
- }else
- {
+ } else {
//Test if it's the right key...
uint8_t i;