Update ikeys.c (#537)
authorIceman <iceman@iuse.se>
Wed, 3 Jan 2018 10:15:46 +0000 (11:15 +0100)
committerpwpiwi <pwpiwi@users.noreply.github.com>
Wed, 3 Jan 2018 10:15:46 +0000 (11:15 +0100)
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

index 72acf6906d6a61bc18db1a6f2e9e604ce543e13d..2a6a00109297c72afe47de08426814f37a510f7e 100644 (file)
@@ -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;
Impressum, Datenschutz