From: Iceman Date: Wed, 3 Jan 2018 10:15:46 +0000 (+0100) Subject: Update ikeys.c (#537) X-Git-Tag: v3.1.0~94 X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/1c313691e6fbd76c48122c8c63844e240a6fb0d1?hp=e1e7a09db1d2fea34ea44c4cadda0c47ccf4269f Update ikeys.c (#537) FIX: 'hf iclass' - sneaky fread bug. It should return same number of bytes as read if ok. Thanks to @bettse who found it. --- diff --git a/client/loclass/ikeys.c b/client/loclass/ikeys.c index 72acf690..2a6a0010 100644 --- a/client/loclass/ikeys.c +++ b/client/loclass/ikeys.c @@ -739,18 +739,16 @@ int readKeyFile(uint8_t key[8]) 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 retval; + + if (fread(key, sizeof(uint8_t), 8, f) == 8) { + retval = 0; } + fclose(f); return retval; } - int doKeyTests(uint8_t debuglevel) { debug_print = debuglevel;