diff --git a/armsrc/Standalone/hf_bog.c b/armsrc/Standalone/hf_bog.c index 7c4b3e5d5..758c5139a 100644 --- a/armsrc/Standalone/hf_bog.c +++ b/armsrc/Standalone/hf_bog.c @@ -76,6 +76,14 @@ static void RAMFUNC SniffAndStore(uint8_t param) { // The DMA buffer, used to stream samples from the FPGA uint8_t *dmaBuf = BigBuf_calloc(DMA_BUFFER_SIZE); + + if (capturedPwds == NULL || receivedCmd == NULL || receivedCmdPar == NULL || + receivedResp == NULL || receivedRespPar == NULL || dmaBuf == NULL) { + if (g_dbglevel >= DBG_ERROR) DbpString("hf bog: failed to allocate buffers"); + BigBuf_free(); + return; + } + uint8_t *data = dmaBuf; uint8_t previous_data = 0; diff --git a/armsrc/Standalone/hf_colin.c b/armsrc/Standalone/hf_colin.c index ab5d68ea6..7d9ca9b48 100644 --- a/armsrc/Standalone/hf_colin.c +++ b/armsrc/Standalone/hf_colin.c @@ -252,6 +252,14 @@ static char *ReadSchemasFromSPIFFS(char *filename) { int changed = rdv40_spiffs_lazy_mount(); uint32_t size = size_in_spiffs((char *)filename); uint8_t *mem = BigBuf_calloc(size); + if (mem == NULL) { + if (changed) { + rdv40_spiffs_lazy_unmount(); + } + SpinOff(0); + return NULL; + } + rdv40_spiffs_read_as_filetype((char *)filename, (uint8_t *)mem, size, RDV40_SPIFFS_SAFETY_SAFE); if (changed) { @@ -264,6 +272,11 @@ static char *ReadSchemasFromSPIFFS(char *filename) { static void __attribute__((noinline)) add_schemas_from_json_in_spiffs(char *filename) { const char *jsonfile = ReadSchemasFromSPIFFS((char *)filename); + if (jsonfile == NULL) { + DbprintfEx(FLAG_NEWLINE, "[!!] out of memory, schemas NOT loaded"); + cjSetCursLeft(); + return; + } int i, len = strlen(jsonfile); struct json_token t; @@ -294,6 +307,12 @@ static void __attribute__((noinline)) ReadLastTagFromFlash(void) { cjSetCursLeft(); uint8_t *mem = BigBuf_calloc(size); + if (mem == NULL) { + DbprintfEx(FLAG_NEWLINE, "[!!] out of memory, last tag NOT recovered"); + cjSetCursLeft(); + SpinOff(0); + return; + } // this one will handle filetype (symlink or not) and resolving by itself rdv40_spiffs_read_as_filetype((char *)HFCOLIN_LASTTAG_SYMLINK, (uint8_t *)mem, len, RDV40_SPIFFS_SAFETY_SAFE); @@ -457,6 +476,13 @@ void RunMod(void) { // Can remember something like that in case of Bigbuf keyBlock = BigBuf_calloc(ARRAYLEN(mfKeys) * MF_KEY_LENGTH); + if (keyBlock == NULL) { + DbprintfEx(FLAG_NEWLINE, "[!!] out of memory, aborting"); + cjSetCursLeft(); + SpinOff(0); + return; + } + int mfKeysCnt = ARRAYLEN(mfKeys); for (int mfKeyCounter = 0; mfKeyCounter < mfKeysCnt; mfKeyCounter++) { diff --git a/armsrc/Standalone/hf_doegox_auth0.c b/armsrc/Standalone/hf_doegox_auth0.c index 2e1c9ff60..09d36e77b 100644 --- a/armsrc/Standalone/hf_doegox_auth0.c +++ b/armsrc/Standalone/hf_doegox_auth0.c @@ -193,6 +193,12 @@ static bool RAMFUNC sniff_wait_for_rnda_reply(tag_t type) { uint8_t *receivedResp = BigBuf_calloc(MAX_FRAME_SIZE); uint8_t *receivedRespPar = BigBuf_calloc(MAX_PARITY_SIZE); + if (receivedCmd == NULL || receivedCmdPar == NULL || + receivedResp == NULL || receivedRespPar == NULL) { + if (g_dbglevel >= DBG_ERROR) DbpString("hf doegox auth0: failed to allocate buffers"); + goto out; + } + uint8_t previous_data = 0; int maxDataLen = 0, dataLen; bool TagIsActive = false; diff --git a/armsrc/Standalone/hf_doegox_commit.c b/armsrc/Standalone/hf_doegox_commit.c index c46f79080..3a4e8b75c 100644 --- a/armsrc/Standalone/hf_doegox_commit.c +++ b/armsrc/Standalone/hf_doegox_commit.c @@ -169,6 +169,12 @@ static bool RAMFUNC sniff_wait_for_commit(tag_t type) { uint8_t *receivedResp = BigBuf_calloc(MAX_FRAME_SIZE); uint8_t *receivedRespPar = BigBuf_calloc(MAX_PARITY_SIZE); + if (receivedCmd == NULL || receivedCmdPar == NULL || + receivedResp == NULL || receivedRespPar == NULL) { + if (g_dbglevel >= DBG_ERROR) DbpString("hf doegox commit: failed to allocate buffers"); + goto out; + } + uint8_t previous_data = 0; int maxDataLen = 0, dataLen; bool TagIsActive = false;