mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-15 09:43:00 -07:00
resource leak and malloc(x) cannot be negative
thanks iceman1001
This commit is contained in:
parent
735136e6a3
commit
d23411ef61
1 changed files with 13 additions and 5 deletions
|
@ -563,15 +563,23 @@ int bruteforceFile(const char *filename, uint16_t keytable[])
|
|||
long fsize = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
if (fsize < 0) {
|
||||
prnlog("Error, when getting fsize");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t *dump = malloc(fsize);
|
||||
size_t bytes_read = fread(dump, 1, fsize, f);
|
||||
|
||||
fclose(f);
|
||||
if (bytes_read < fsize)
|
||||
{
|
||||
if (bytes_read < fsize) {
|
||||
prnlog("Error, could only read %d bytes (should be %d)",bytes_read, fsize );
|
||||
}
|
||||
return bruteforceDump(dump,fsize,keytable);
|
||||
|
||||
uint8_t res = bruteforceDump(dump,fsize,keytable);
|
||||
free(dump);
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue