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

FIX: forgot to close the filehandle :(
This commit is contained in:
iceman1001 2016-01-12 22:47:48 +01:00
commit 4bb17c6633

View file

@ -286,10 +286,10 @@ int CmdHFiClassELoad(const char *Cmd) {
if (fsize < 0) { if (fsize < 0) {
prnlog("Error, when getting filesize"); prnlog("Error, when getting filesize");
fclose(f);
return 1; return 1;
} }
uint8_t *dump = malloc(fsize); uint8_t *dump = malloc(fsize);
size_t bytes_read = fread(dump, 1, fsize, f); size_t bytes_read = fread(dump, 1, fsize, f);
@ -1509,6 +1509,12 @@ static int loadKeys(char *filename) {
long fsize = ftell(f); long fsize = ftell(f);
fseek(f, 0, SEEK_SET); fseek(f, 0, SEEK_SET);
if ( fsize < 0 ) {
PrintAndLog("Error, when getting filesize");
fclose(f);
return 1;
}
uint8_t *dump = malloc(fsize); uint8_t *dump = malloc(fsize);
size_t bytes_read = fread(dump, 1, fsize, f); size_t bytes_read = fread(dump, 1, fsize, f);