FIX: 'hf iclass' - sneaky fread bug. thanks to @bettse who found it

This commit is contained in:
iceman1001 2018-01-01 14:28:53 +01:00
commit f92a6ddf7d

View file

@ -675,23 +675,22 @@ int doTestsWithKnownInputs() {
return errors; return errors;
} }
int readKeyFile(uint8_t key[8]) { static bool readKeyFile(uint8_t key[8]) {
int retval = 1; bool retval = false;
FILE *f = fopen("iclass_key.bin", "rb"); FILE *f = fopen("iclass_key.bin", "rb");
if (!f) if (!f)
return 0; return retval;
size_t bytes_read = fread(key, sizeof(uint8_t), 8, f); size_t bytes_read = fread(key, sizeof(uint8_t), sizeof(key), f);
if ( bytes_read == 1) if ( bytes_read == sizeof(key))
retval = 0; retval = true;
if (f) if (f)
fclose(f); fclose(f);
return retval; return retval;
} }
int doKeyTests(uint8_t debuglevel) int doKeyTests(uint8_t debuglevel) {
{
debug_print = debuglevel; debug_print = debuglevel;
prnlog("[+] Checking if the master key is present (iclass_key.bin)..."); prnlog("[+] Checking if the master key is present (iclass_key.bin)...");