From 2464cf60fded1a5899c5ae7c529d5d512199f1aa Mon Sep 17 00:00:00 2001 From: Jakub Kramarz Date: Mon, 27 Jan 2025 11:26:08 +0100 Subject: [PATCH] sam_seos, sam_picopass: switch from static allocation to BigBuf --- armsrc/sam_picopass.c | 9 +++++++-- armsrc/sam_seos.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/armsrc/sam_picopass.c b/armsrc/sam_picopass.c index f493e852b..450e46253 100644 --- a/armsrc/sam_picopass.c +++ b/armsrc/sam_picopass.c @@ -49,8 +49,12 @@ static int sam_send_request_iso15(const uint8_t *const request, const uint8_t re if (g_dbglevel >= DBG_DEBUG) DbpString("start sam_send_request_iso14a"); - uint8_t buf1[ISO7816_MAX_FRAME] = {0}; - uint8_t buf2[ISO7816_MAX_FRAME] = {0}; + uint8_t * buf1 = BigBuf_malloc(ISO7816_MAX_FRAME); + uint8_t * buf2 = BigBuf_malloc(ISO7816_MAX_FRAME); + if(buf1 == NULL || buf2 == NULL){ + res = PM3_EMALLOC; + goto out; + } uint8_t *sam_tx_buf = buf1; uint16_t sam_tx_len; @@ -235,6 +239,7 @@ static int sam_send_request_iso15(const uint8_t *const request, const uint8_t re goto out; out: + BigBuf_free(); return res; } diff --git a/armsrc/sam_seos.c b/armsrc/sam_seos.c index 0f4a7f223..492a684a9 100644 --- a/armsrc/sam_seos.c +++ b/armsrc/sam_seos.c @@ -129,8 +129,12 @@ static int sam_send_request_iso14a(const uint8_t *const request, const uint8_t r if (g_dbglevel >= DBG_DEBUG) DbpString("start sam_send_request_iso14a"); - uint8_t buf1[ISO7816_MAX_FRAME] = {0}; - uint8_t buf2[ISO7816_MAX_FRAME] = {0}; + uint8_t * buf1 = BigBuf_malloc(ISO7816_MAX_FRAME); + uint8_t * buf2 = BigBuf_malloc(ISO7816_MAX_FRAME); + if(buf1 == NULL || buf2 == NULL){ + res = PM3_EMALLOC; + goto out; + } uint8_t *sam_tx_buf = buf1; uint16_t sam_tx_len; @@ -253,6 +257,7 @@ static int sam_send_request_iso14a(const uint8_t *const request, const uint8_t r goto out; out: + BigBuf_free(); return res; }