From: iceman1001 Date: Tue, 12 Jan 2016 21:49:29 +0000 (+0100) Subject: FIX, Coverity, Argument can't be negative, CID #212324, ftell(f) can be negative... X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/ddb748a973bdcb84c6a0ab21e5fcd2b964e5c2e5?ds=sidebyside;hp=4bb17c66333da6ac8ed6c4757f8377d37f7f7e24 FIX, Coverity, Argument can't be negative, CID #212324, ftell(f) can be negative, not allowed in malloc. --- diff --git a/client/cmdhficlass.c b/client/cmdhficlass.c index 86524cd6..5f45ab1a 100644 --- a/client/cmdhficlass.c +++ b/client/cmdhficlass.c @@ -1316,8 +1316,13 @@ int CmdHFiClassReadTagFile(const char *Cmd) { long fsize = ftell(f); fseek(f, 0, SEEK_SET); - uint8_t *dump = malloc(fsize); + 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); fclose(f);