]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/loclass/elite_crack.c
FIX: too small string?
[proxmark3-svn] / client / loclass / elite_crack.c
index 2329e597d3f708a537b30a24e785c737607294c7..2395a178802554c25cdfddab7c160fb9bf2d58b5 100644 (file)
@@ -522,8 +522,8 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[])
                errors += bruteforceItem(*attack, keytable);
        }
        free(attack);
                errors += bruteforceItem(*attack, keytable);
        }
        free(attack);
-       clock_t t2 = clock();
-       float diff = (((float)t2 - (float)t1) / CLOCKS_PER_SEC );
+       t1 = clock() - t1;
+       float diff = ((float)t1 / CLOCKS_PER_SEC );
        prnlog("\nPerformed full crack in %f seconds",diff);
 
        // Pick out the first 16 bytes of the keytable.
        prnlog("\nPerformed full crack in %f seconds",diff);
 
        // Pick out the first 16 bytes of the keytable.
@@ -552,7 +552,6 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[])
  */
 int bruteforceFile(const char *filename, uint16_t keytable[])
 {
  */
 int bruteforceFile(const char *filename, uint16_t keytable[])
 {
-
        FILE *f = fopen(filename, "rb");
        if(!f) {
                prnlog("Failed to read from file '%s'", filename);
        FILE *f = fopen(filename, "rb");
        if(!f) {
                prnlog("Failed to read from file '%s'", filename);
@@ -565,19 +564,23 @@ int bruteforceFile(const char *filename, uint16_t keytable[])
 
        if (fsize < 0) {
                prnlog("Error, when getting filesize");
 
        if (fsize < 0) {
                prnlog("Error, when getting filesize");
-               fclose(f);
+               if (f) {
+                       fclose(f);
+                       f = NULL;
+               }
                return 1;
        }
 
        uint8_t *dump = malloc(fsize);
        size_t bytes_read = fread(dump, 1, fsize, f);
 
                return 1;
        }
 
        uint8_t *dump = malloc(fsize);
        size_t bytes_read = fread(dump, 1, fsize, f);
 
-       fclose(f);
-    if (bytes_read < fsize)
-    {
+       if (f) {
+               fclose(f);
+               f = NULL;
+       }
+    if (bytes_read < fsize) {
         prnlog("Error, could only read %d bytes (should be %d)",bytes_read, fsize );
     }
         prnlog("Error, could only read %d bytes (should be %d)",bytes_read, fsize );
     }
-
        uint8_t res = bruteforceDump(dump,fsize,keytable);
        free(dump);
        return res;
        uint8_t res = bruteforceDump(dump,fsize,keytable);
        free(dump);
        return res;
Impressum, Datenschutz