mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-04-13 16:00:02 +08:00
FIX, Coverity, Argument can't be negative. CID# 212322, ftell(f) can be negative. Not allowed in malloc...
This commit is contained in:
parent
7144c99b07
commit
9c4e28a445
1 changed files with 8 additions and 4 deletions
|
@ -269,8 +269,7 @@ int CmdHFiClassELoad(const char *Cmd) {
|
||||||
//File handling and reading
|
//File handling and reading
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char filename[FILE_PATH_SIZE];
|
char filename[FILE_PATH_SIZE];
|
||||||
if(opt == 'f' && param_getstr(Cmd, 1, filename) > 0)
|
if(opt == 'f' && param_getstr(Cmd, 1, filename) > 0) {
|
||||||
{
|
|
||||||
f = fopen(filename, "rb");
|
f = fopen(filename, "rb");
|
||||||
} else {
|
} else {
|
||||||
return hf_iclass_eload_usage();
|
return hf_iclass_eload_usage();
|
||||||
|
@ -285,9 +284,14 @@ int CmdHFiClassELoad(const char *Cmd) {
|
||||||
long fsize = ftell(f);
|
long fsize = ftell(f);
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
uint8_t *dump = malloc(fsize);
|
if (fsize < 0) {
|
||||||
|
prnlog("Error, when getting filesize");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t *dump = malloc(fsize);
|
||||||
|
|
||||||
size_t bytes_read = fread(dump, 1, fsize, f);
|
size_t bytes_read = fread(dump, 1, fsize, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue