FIX, Coverity, Argument can't be negative, CID #212324, ftell(f) can be negative, not allowed in malloc.

This commit is contained in:
iceman1001 2016-01-12 22:49:29 +01:00
parent 4bb17c6633
commit ddb748a973

View file

@ -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);