diff --git a/client/cmdflashmem.c b/client/cmdflashmem.c index 1dd3084d9..2ff68bd3d 100644 --- a/client/cmdflashmem.c +++ b/client/cmdflashmem.c @@ -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; diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index d46344451..1bfbf10eb 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -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) {