From eb5b63b4a6b07fb9d7034c11d99408033613b1d5 Mon Sep 17 00:00:00 2001 From: marshmellow42 Date: Sun, 14 Feb 2016 12:13:22 -0500 Subject: [PATCH] =?utf8?q?FIX,=20Coverity,=20Argument=20can't=20be=20negat?= =?utf8?q?ive.=20CID#=20212322,=20ftell(f)=20can=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit …be negative. Not allowed in malloc... from iceman1001 --- client/cmdhficlass.c | 7 +++++++ 1 file changed, 7 insertions(+) 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); -- 2.39.5