]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
FIX, Coverity, Argument can't be negative. CID# 212322, ftell(f) can …
authormarshmellow42 <marshmellowrf@gmail.com>
Sun, 14 Feb 2016 17:06:29 +0000 (12:06 -0500)
committermarshmellow42 <marshmellowrf@gmail.com>
Sun, 14 Feb 2016 17:06:29 +0000 (12:06 -0500)
…be negative. Not allowed in malloc...
from @iceman1001

client/cmdhficlass.c

index 59b0ddc3cff115b2e5b4710a514d52d6c0b5d27e..a169e827663f7fd0e13247d100784b31418c11c8 100644 (file)
@@ -283,8 +283,12 @@ int CmdHFiClassELoad(const char *Cmd) {
        long fsize = ftell(f);
        fseek(f, 0, SEEK_SET);
 
        long fsize = ftell(f);
        fseek(f, 0, SEEK_SET);
 
-       uint8_t *dump = malloc(fsize);
+       if (fsize < 0) {
+               PrintAndLog("Error, when getting filesize");
+               return 1;
+       }
 
 
+       uint8_t *dump = malloc(fsize);
 
        size_t bytes_read = fread(dump, 1, fsize, f);
        fclose(f);
 
        size_t bytes_read = fread(dump, 1, fsize, f);
        fclose(f);
Impressum, Datenschutz