for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {\r
for(blockNo = 0; blockNo < NumBlocksPerSector(sectorNo); blockNo++) {\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
+ memcpy(c.d.asBytes, key, 6); \r
+ bytes_read = fread(bldata, 1, 16, fdump);\r
+ if ( bytes_read == 0) {\r
PrintAndLog("File reading error (dumpdata.bin).");\r
fclose(fdump);\r
return 2;\r