DesfireExchangeEx dyn memory

This commit is contained in:
merlokk 2021-12-24 11:51:23 +02:00
commit 02316e5fc3

View file

@ -799,7 +799,9 @@ int DesfireExchangeEx(bool activate_field, DesfireContext_t *ctx, uint8_t cmd, u
if (!PrintChannelModeWarning(cmd, ctx->secureChannel, ctx->cmdSet, ctx->commMode)) if (!PrintChannelModeWarning(cmd, ctx->secureChannel, ctx->cmdSet, ctx->commMode))
DesfirePrintContext(ctx); DesfirePrintContext(ctx);
uint8_t databuf[250 * 5] = {0}; uint8_t *databuf = calloc(DESFIRE_BUFFER_SIZE, 1);
if (databuf == NULL)
return PM3_EMALLOC;
size_t databuflen = 0; size_t databuflen = 0;
switch (ctx->cmdSet) { switch (ctx->cmdSet) {
@ -828,10 +830,12 @@ int DesfireExchangeEx(bool activate_field, DesfireContext_t *ctx, uint8_t cmd, u
} }
break; break;
case DCCISO: case DCCISO:
free(databuf);
return PM3_EAPDU_FAIL; return PM3_EAPDU_FAIL;
break; break;
} }
free(databuf);
return res; return res;
} }