mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
Change calloc() so it passes Widnows build test
Code compiles under linux (not tested yet, I have no proxmark available right now)
Previous commit fails windows build test with:
src/cmdhfmfu.c: In function 'CmdHF14AMfuESave':
src/cmdhfmfu.c:4220:19: error: array subscript 'mfu_dump_t[0]' is partly outside array bounds of 'mfu_dump_t[0]' [-Werror=array-bounds]
4220 | end = dump->pages ;
| ^~
In function 'GetMfuDumpFromEMul',
inlined from 'CmdHF14AMfuESave' at src/cmdhfmfu.c:4202:15:
src/cmdhfmfu.c:4105:21: note: object of size 1076 allocated by 'calloc'
4105 | uint8_t *dump = calloc(MFU_MAX_BYTES + MFU_DUMP_PREFIX_LENGTH, sizeof(uint8_t));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This commit is contained in:
@@ -4102,20 +4102,20 @@ int CmdHF14MfuNDEFRead(const char *Cmd) {
|
||||
// utility function. Retrieves emulator memory
|
||||
static int GetMfuDumpFromEMul(mfu_dump_t **buf) {
|
||||
|
||||
uint8_t *dump = calloc(MFU_MAX_BYTES + MFU_DUMP_PREFIX_LENGTH, sizeof(uint8_t));
|
||||
mfu_dump_t *dump = calloc(1, sizeof(mfu_dump_t));
|
||||
if (dump == NULL) {
|
||||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
PrintAndLogEx(INFO, "downloading from emulator memory");
|
||||
if (!GetFromDevice(BIG_BUF_EML, dump, sizeof(mfu_dump_t), 0, NULL, 0, NULL, 2500, false)) {
|
||||
if (!GetFromDevice(BIG_BUF_EML, (uint8_t *)dump, MFU_MAX_BYTES + MFU_DUMP_PREFIX_LENGTH, 0, NULL, 0, NULL, 2500, false)) {
|
||||
PrintAndLogEx(WARNING, "Fail, transfer from device time-out");
|
||||
free(dump);
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
*buf = (mfu_dump_t *)dump ;
|
||||
*buf = dump ;
|
||||
return PM3_SUCCESS ;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user