add NULL checks
This commit is contained in:
1 parent
e3429580fd
commit
57f8613b83
4 files changed
+46
No files matched your search
@@ -76,6 +76,14 @@ static void RAMFUNC SniffAndStore(uint8_t param) {
|
|||||||
|
|
||||||
// The DMA buffer, used to stream samples from the FPGA
|
// The DMA buffer, used to stream samples from the FPGA
|
||||||
uint8_t *dmaBuf = BigBuf_calloc(DMA_BUFFER_SIZE);
|
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 *data = dmaBuf;
|
||||||
|
|
||||||
uint8_t previous_data = 0;
|
uint8_t previous_data = 0;
|
||||||
|
|||||||
@@ -252,6 +252,14 @@ static char *ReadSchemasFromSPIFFS(char *filename) {
|
|||||||
int changed = rdv40_spiffs_lazy_mount();
|
int changed = rdv40_spiffs_lazy_mount();
|
||||||
uint32_t size = size_in_spiffs((char *)filename);
|
uint32_t size = size_in_spiffs((char *)filename);
|
||||||
uint8_t *mem = BigBuf_calloc(size);
|
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);
|
rdv40_spiffs_read_as_filetype((char *)filename, (uint8_t *)mem, size, RDV40_SPIFFS_SAFETY_SAFE);
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
@@ -264,6 +272,11 @@ static char *ReadSchemasFromSPIFFS(char *filename) {
|
|||||||
static void __attribute__((noinline)) add_schemas_from_json_in_spiffs(char *filename) {
|
static void __attribute__((noinline)) add_schemas_from_json_in_spiffs(char *filename) {
|
||||||
|
|
||||||
const char *jsonfile = ReadSchemasFromSPIFFS((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);
|
int i, len = strlen(jsonfile);
|
||||||
struct json_token t;
|
struct json_token t;
|
||||||
@@ -294,6 +307,12 @@ static void __attribute__((noinline)) ReadLastTagFromFlash(void) {
|
|||||||
cjSetCursLeft();
|
cjSetCursLeft();
|
||||||
|
|
||||||
uint8_t *mem = BigBuf_calloc(size);
|
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
|
// 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);
|
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
|
// Can remember something like that in case of Bigbuf
|
||||||
keyBlock = BigBuf_calloc(ARRAYLEN(mfKeys) * MF_KEY_LENGTH);
|
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);
|
int mfKeysCnt = ARRAYLEN(mfKeys);
|
||||||
|
|
||||||
for (int mfKeyCounter = 0; mfKeyCounter < mfKeysCnt; mfKeyCounter++) {
|
for (int mfKeyCounter = 0; mfKeyCounter < mfKeysCnt; mfKeyCounter++) {
|
||||||
|
|||||||
@@ -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 *receivedResp = BigBuf_calloc(MAX_FRAME_SIZE);
|
||||||
uint8_t *receivedRespPar = BigBuf_calloc(MAX_PARITY_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;
|
uint8_t previous_data = 0;
|
||||||
int maxDataLen = 0, dataLen;
|
int maxDataLen = 0, dataLen;
|
||||||
bool TagIsActive = false;
|
bool TagIsActive = false;
|
||||||
|
|||||||
@@ -169,6 +169,12 @@ static bool RAMFUNC sniff_wait_for_commit(tag_t type) {
|
|||||||
uint8_t *receivedResp = BigBuf_calloc(MAX_FRAME_SIZE);
|
uint8_t *receivedResp = BigBuf_calloc(MAX_FRAME_SIZE);
|
||||||
uint8_t *receivedRespPar = BigBuf_calloc(MAX_PARITY_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;
|
uint8_t previous_data = 0;
|
||||||
int maxDataLen = 0, dataLen;
|
int maxDataLen = 0, dataLen;
|
||||||
bool TagIsActive = false;
|
bool TagIsActive = false;
|
||||||
|
|||||||
Reference in new issue
Block a user