Skip to content

Commit

Permalink
Change calloc() so it passes Widnows build test
Browse files Browse the repository at this point in the history
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));
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • Loading branch information
DidierA committed Nov 23, 2022
1 parent 182d167 commit d4f08ab
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions client/src/cmdhfmfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
}

Expand Down

0 comments on commit d4f08ab

Please sign in to comment.