mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-12 19:23:54 +08:00
FIX: 'mem load' - bad memory allocation
CHG: calloc fixes
This commit is contained in:
parent
cecf709fe7
commit
a963a7834c
2 changed files with 6 additions and 4 deletions
|
@ -182,9 +182,9 @@ int CmdFlashMemLoad(const char *Cmd){
|
|||
//Validations
|
||||
if (errors || cmdp == 0 ) return usage_flashmem_load();
|
||||
|
||||
uint8_t *data = NULL;
|
||||
uint8_t *data = calloc(FLASH_MEM_MAX_SIZE, sizeof(uint8_t));
|
||||
size_t datalen = 0;
|
||||
int res = loadFile(filename, "bin", &data, &datalen);
|
||||
int res = loadFile(filename, "bin", data, &datalen);
|
||||
//int res = loadFileEML( filename, "eml", data, &datalen);
|
||||
if ( res ) {
|
||||
free(data);
|
||||
|
@ -196,6 +196,8 @@ int CmdFlashMemLoad(const char *Cmd){
|
|||
free(data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
data = realloc(data, datalen);
|
||||
|
||||
//Send to device
|
||||
uint32_t bytes_sent = 0;
|
||||
|
|
|
@ -2414,7 +2414,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
|||
|
||||
param_getstr(Cmd, nameParamNo, filename, sizeof(filename));
|
||||
|
||||
uint8_t *data = calloc(1, 4096);
|
||||
uint8_t *data = calloc(4096, sizeof(uint8_t));
|
||||
size_t datalen = 0;
|
||||
//int res = loadFile(filename, "bin", data, &datalen);
|
||||
int res = loadFileEML( filename, "eml", data, &datalen);
|
||||
|
@ -2693,7 +2693,7 @@ int CmdHF14AMfCLoad(const char *Cmd) {
|
|||
}
|
||||
|
||||
size_t maxdatalen = 4096;
|
||||
uint8_t *data = calloc(1, maxdatalen);
|
||||
uint8_t *data = calloc(maxdatalen, sizeof(uint8_t));
|
||||
size_t datalen = 0;
|
||||
int res = 0;
|
||||
if (fillFromBin) {
|
||||
|
|
Loading…
Reference in a new issue