From: marshmellow42 Date: Sun, 14 Feb 2016 17:13:22 +0000 (-0500) Subject: FIX, Coverity, Argument can't be negative. CID# 212322, ftell(f) can … X-Git-Tag: v2.3.0~7^2~11 X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/eb5b63b4a6b07fb9d7034c11d99408033613b1d5 FIX, Coverity, Argument can't be negative. CID# 212322, ftell(f) can … …be negative. Not allowed in malloc... from iceman1001 --- diff --git a/client/cmdhficlass.c b/client/cmdhficlass.c index a169e827..67bcbe76 100644 --- a/client/cmdhficlass.c +++ b/client/cmdhficlass.c @@ -285,6 +285,7 @@ int CmdHFiClassELoad(const char *Cmd) { if (fsize < 0) { PrintAndLog("Error, when getting filesize"); + fclose(f); return 1; } @@ -1506,6 +1507,12 @@ static int loadKeys(char *filename) { long fsize = ftell(f); fseek(f, 0, SEEK_SET); + if ( fsize < 0 ) { + PrintAndLog("Error, when getting filesize"); + fclose(f); + return 1; + } + uint8_t *dump = malloc(fsize); size_t bytes_read = fread(dump, 1, fsize, f);