fix: wrong size when going to calloc

This commit is contained in:
iceman1001 2019-10-09 10:39:36 +02:00
commit ba461b8e1b

View file

@ -2554,18 +2554,19 @@ static int CmdResetRead(const char *Cmd) {
if (resp.status == PM3_SUCCESS) { if (resp.status == PM3_SUCCESS) {
uint8_t *got = calloc(BIGBUF_SIZE - 1, sizeof(uint8_t)); uint16_t gotsize = BIGBUF_SIZE - 1;
uint8_t *got = calloc(gotsize, sizeof(uint8_t));
if (got == NULL) { if (got == NULL) {
PrintAndLogEx(WARNING, "failed to allocate memory"); PrintAndLogEx(WARNING, "failed to allocate memory");
return PM3_EMALLOC; return PM3_EMALLOC;
} }
if (!GetFromDevice(BIG_BUF, got, sizeof(got), 0, NULL, 0, NULL, 2500, false)) { if (!GetFromDevice(BIG_BUF, got, gotsize, 0, NULL, 0, NULL, 2500, false)) {
PrintAndLogEx(WARNING, "command execution time out"); PrintAndLogEx(WARNING, "command execution time out");
free(got); free(got);
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
} }
setGraphBuf(got, sizeof(got)); setGraphBuf(got, gotsize);
free(got); free(got);
} }
return PM3_SUCCESS; return PM3_SUCCESS;