mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-10-06 14:17:46 +00:00
add NULL checks
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user