From: iceman1001 Date: Tue, 12 Jan 2016 21:47:48 +0000 (+0100) Subject: FIX: Coverity , Argument can't be negative, CID #121323, ftell(f) can be negative... X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/4bb17c66333da6ac8ed6c4757f8377d37f7f7e24 FIX: Coverity , Argument can't be negative, CID #121323, ftell(f) can be negative, not allowed in malloc. FIX: forgot to close the filehandle :( --- diff --git a/client/cmdhficlass.c b/client/cmdhficlass.c index d4750735..86524cd6 100644 --- a/client/cmdhficlass.c +++ b/client/cmdhficlass.c @@ -286,10 +286,10 @@ int CmdHFiClassELoad(const char *Cmd) { 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); @@ -1509,6 +1509,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);