]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
resource leak and malloc(x) cannot be negative
authormarshmellow42 <marshmellowrf@gmail.com>
Sun, 14 Feb 2016 18:41:25 +0000 (13:41 -0500)
committermarshmellow42 <marshmellowrf@gmail.com>
Sun, 14 Feb 2016 18:41:25 +0000 (13:41 -0500)
thanks iceman1001

client/loclass/elite_crack.c

index c824eaa188ed45c56fce156718c4dfeda90f5b19..5dd8bf6dff0eb4d24d8009a749c5ca6842acb0ac 100644 (file)
@@ -563,15 +563,23 @@ int bruteforceFile(const char *filename, uint16_t keytable[])
        long fsize = ftell(f);
        fseek(f, 0, SEEK_SET);
 
+       if (fsize < 0) {
+               prnlog("Error, when getting fsize");
+               fclose(f);
+               return 1;
+       }
+
        uint8_t *dump = malloc(fsize);
        size_t bytes_read = fread(dump, 1, fsize, f);
 
        fclose(f);
-    if (bytes_read < fsize)
-    {
-        prnlog("Error, could only read %d bytes (should be %d)",bytes_read, fsize );
-    }
-       return bruteforceDump(dump,fsize,keytable);
+       if (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;
 }
 /**
  *
Impressum, Datenschutz