]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
FIX: Coverity, resource leak, and variable can't be negative,
authoriceman1001 <iceman@iuse.se>
Wed, 13 Jan 2016 12:22:25 +0000 (13:22 +0100)
committericeman1001 <iceman@iuse.se>
Wed, 13 Jan 2016 12:22:25 +0000 (13:22 +0100)
client/loclass/elite_crack.c

index c824eaa188ed45c56fce156718c4dfeda90f5b19..2329e597d3f708a537b30a24e785c737607294c7 100644 (file)
@@ -563,6 +563,12 @@ int bruteforceFile(const char *filename, uint16_t keytable[])
        long fsize = ftell(f);
        fseek(f, 0, SEEK_SET);
 
+       if (fsize < 0) {
+               prnlog("Error, when getting filesize");
+               fclose(f);
+               return 1;
+       }
+
        uint8_t *dump = malloc(fsize);
        size_t bytes_read = fread(dump, 1, fsize, f);
 
@@ -571,7 +577,10 @@ int bruteforceFile(const char *filename, uint16_t keytable[])
     {
         prnlog("Error, could only read %d bytes (should be %d)",bytes_read, fsize );
     }
-       return bruteforceDump(dump,fsize,keytable);
+
+       uint8_t res = bruteforceDump(dump,fsize,keytable);
+       free(dump);
+       return res;
 }
 /**
  *
Impressum, Datenschutz