From ddb748a973bdcb84c6a0ab21e5fcd2b964e5c2e5 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 12 Jan 2016 22:49:29 +0100 Subject: [PATCH] FIX, Coverity, Argument can't be negative, CID #212324, ftell(f) can be negative, not allowed in malloc. --- client/cmdhficlass.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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); -- 2.39.5