From 1c313691e6fbd76c48122c8c63844e240a6fb0d1 Mon Sep 17 00:00:00 2001 From: Iceman Date: Wed, 3 Jan 2018 11:15:46 +0100 Subject: [PATCH 1/1] 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. --- client/loclass/ikeys.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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; -- 2.39.2