final batch of adding NULL checks
This commit is contained in:
1 parent
0cfe0e0e8d
commit
e6c1c4e1a7
11 files changed
+66
No files matched your search
@@ -269,6 +269,11 @@ void RunMod(void) {
|
|||||||
sizeof(uint64_t) * (ARRAYLEN(MATTYRUN_MFC_ESSENTIAL_KEYS) +
|
sizeof(uint64_t) * (ARRAYLEN(MATTYRUN_MFC_ESSENTIAL_KEYS) +
|
||||||
ARRAYLEN(MATTYRUN_MFC_DEFAULT_KEYS) +
|
ARRAYLEN(MATTYRUN_MFC_DEFAULT_KEYS) +
|
||||||
MIFARE_4K_MAXSECTOR * 2));
|
MIFARE_4K_MAXSECTOR * 2));
|
||||||
|
if (mfcKeys == NULL) {
|
||||||
|
DbpString("Failed to allocate memory");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t mfcKeyCount = 0;
|
uint16_t mfcKeyCount = 0;
|
||||||
|
|
||||||
// Load essential keys to dictionary buffer
|
// Load essential keys to dictionary buffer
|
||||||
|
|||||||
@@ -104,6 +104,11 @@ static bool get_input_data_from_file(uint32_t *tag, char *inputfile) {
|
|||||||
|
|
||||||
uint32_t size = size_in_spiffs(inputfile);
|
uint32_t size = size_in_spiffs(inputfile);
|
||||||
uint8_t *mem = BigBuf_calloc(size);
|
uint8_t *mem = BigBuf_calloc(size);
|
||||||
|
if (mem == NULL) {
|
||||||
|
Dbprintf(_RED_("failed to allocate memory for %s"), inputfile);
|
||||||
|
BigBuf_free();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Dbprintf("found input file `" _YELLOW_("%s") "`", inputfile);
|
Dbprintf("found input file `" _YELLOW_("%s") "`", inputfile);
|
||||||
|
|
||||||
|
|||||||
@@ -335,6 +335,9 @@ void cmac(const desfirekey_t key, uint8_t *ivect, const uint8_t *data, size_t le
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *buffer = BigBuf_calloc(padded_data_length(len, kbs));
|
uint8_t *buffer = BigBuf_calloc(padded_data_length(len, kbs));
|
||||||
|
if (buffer == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(buffer, data, len);
|
memcpy(buffer, data, len);
|
||||||
|
|
||||||
|
|||||||
@@ -756,6 +756,17 @@ void em4x50_chk(const char *filename, bool ledcontrol) {
|
|||||||
uint32_t size = size_in_spiffs(filename);
|
uint32_t size = size_in_spiffs(filename);
|
||||||
pwd_count = size / 4;
|
pwd_count = size / 4;
|
||||||
uint8_t *pwds = BigBuf_calloc(size);
|
uint8_t *pwds = BigBuf_calloc(size);
|
||||||
|
if (pwds == NULL) {
|
||||||
|
if (changed) {
|
||||||
|
rdv40_spiffs_lazy_unmount();
|
||||||
|
}
|
||||||
|
BigBuf_free();
|
||||||
|
if (ledcontrol) LEDsoff();
|
||||||
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
|
StopTicks();
|
||||||
|
reply_ng(CMD_LF_EM4X50_CHK, PM3_EMALLOC, (uint8_t *)&pwd, sizeof(pwd));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
rdv40_spiffs_read_as_filetype(filename, pwds, size, RDV40_SPIFFS_SAFETY_SAFE);
|
rdv40_spiffs_read_as_filetype(filename, pwds, size, RDV40_SPIFFS_SAFETY_SAFE);
|
||||||
|
|
||||||
|
|||||||
@@ -209,6 +209,12 @@ int HfSimulateTkm(const uint8_t *uid, uint8_t modulation, uint32_t timeout) {
|
|||||||
LEDsoff();
|
LEDsoff();
|
||||||
|
|
||||||
uint8_t *data = BigBuf_calloc(256);
|
uint8_t *data = BigBuf_calloc(256);
|
||||||
|
if (data == NULL) {
|
||||||
|
DbpString("Failed to allocate memory");
|
||||||
|
reply_ng(CMD_HF_TEXKOM_SIMULATE, PM3_EMALLOC, NULL, 0);
|
||||||
|
return PM3_EMALLOC;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t elen = HfEncodeTkm(uid, modulation, data);
|
uint32_t elen = HfEncodeTkm(uid, modulation, data);
|
||||||
if (elen == 0) {
|
if (elen == 0) {
|
||||||
DbpString("encode error");
|
DbpString("encode error");
|
||||||
|
|||||||
@@ -109,6 +109,15 @@ int HfSniff(uint32_t samplesToSkip, uint32_t triggersToSkip, uint16_t *len, uint
|
|||||||
|
|
||||||
*len = BigBuf_max_traceLen();
|
*len = BigBuf_max_traceLen();
|
||||||
uint8_t *mem = BigBuf_calloc(*len);
|
uint8_t *mem = BigBuf_calloc(*len);
|
||||||
|
if (mem == NULL) {
|
||||||
|
Dbprintf("Failed to allocate memory");
|
||||||
|
FpgaUpdateFrameMode(8, true, true);
|
||||||
|
LED_D_OFF();
|
||||||
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
|
BigBuf_free();
|
||||||
|
*len = 0;
|
||||||
|
return PM3_EMALLOC;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t trigger_cnt = 0;
|
uint32_t trigger_cnt = 0;
|
||||||
uint16_t r = 0, interval = 0;
|
uint16_t r = 0, interval = 0;
|
||||||
|
|||||||
@@ -1726,6 +1726,13 @@ void SniffHitag2(bool ledcontrol, uint8_t threshold) {
|
|||||||
auth_table_pos = 0;
|
auth_table_pos = 0;
|
||||||
|
|
||||||
auth_table = (uint8_t *)BigBuf_calloc(AUTH_TABLE_LENGTH);
|
auth_table = (uint8_t *)BigBuf_calloc(AUTH_TABLE_LENGTH);
|
||||||
|
if (auth_table == NULL) {
|
||||||
|
DbpString("Failed to allocate memory");
|
||||||
|
if (ledcontrol) LEDsoff();
|
||||||
|
switch_off();
|
||||||
|
BigBuf_free_keep_EM();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Only for debug, if we want to see the edge timing of the captured frames
|
// Only for debug, if we want to see the edge timing of the captured frames
|
||||||
uint8_t edges[100];
|
uint8_t edges[100];
|
||||||
|
|||||||
@@ -152,6 +152,11 @@ void initSampleBufferEx(uint32_t *sample_size, bool use_malloc) {
|
|||||||
} else {
|
} else {
|
||||||
*sample_size = MIN(*sample_size, BigBuf_max_traceLen());
|
*sample_size = MIN(*sample_size, BigBuf_max_traceLen());
|
||||||
data.buffer = BigBuf_calloc(*sample_size);
|
data.buffer = BigBuf_calloc(*sample_size);
|
||||||
|
if (data.buffer == NULL) {
|
||||||
|
Dbprintf("Failed to allocate memory, using whole BigBuf");
|
||||||
|
*sample_size = BigBuf_max_traceLen();
|
||||||
|
data.buffer = BigBuf_get_addr();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ void RAMFUNC SniffMifare(uint8_t param) {
|
|||||||
|
|
||||||
// allocate the DMA buffer, used to stream samples from the FPGA
|
// allocate the DMA buffer, used to stream samples from the FPGA
|
||||||
uint8_t *dmaBuf = BigBuf_malloc(DMA_BUFFER_SIZE);
|
uint8_t *dmaBuf = BigBuf_malloc(DMA_BUFFER_SIZE);
|
||||||
|
if (dmaBuf == NULL) {
|
||||||
|
if (g_dbglevel >= DBG_ERROR) Dbprintf("Failed to allocate memory");
|
||||||
|
return;
|
||||||
|
}
|
||||||
uint8_t *data = dmaBuf;
|
uint8_t *data = dmaBuf;
|
||||||
uint8_t previous_data = 0;
|
uint8_t previous_data = 0;
|
||||||
int dataLen, maxDataLen = 0;
|
int dataLen, maxDataLen = 0;
|
||||||
|
|||||||
@@ -548,6 +548,10 @@ static int sam_set_card_detected_picopass(const picopass_hdr_t *card_select) {
|
|||||||
}
|
}
|
||||||
uint8_t *response = BigBuf_calloc(ISO7816_MAX_FRAME);
|
uint8_t *response = BigBuf_calloc(ISO7816_MAX_FRAME);
|
||||||
uint16_t response_len = ISO7816_MAX_FRAME;
|
uint16_t response_len = ISO7816_MAX_FRAME;
|
||||||
|
if (response == NULL) {
|
||||||
|
res = PM3_EMALLOC;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
// a0 12
|
// a0 12
|
||||||
// ad 10
|
// ad 10
|
||||||
|
|||||||
@@ -46,6 +46,13 @@ void ReadThinFilm(void) {
|
|||||||
|
|
||||||
uint8_t len = 0;
|
uint8_t len = 0;
|
||||||
uint8_t *buf = BigBuf_calloc(36);
|
uint8_t *buf = BigBuf_calloc(36);
|
||||||
|
if (buf == NULL) {
|
||||||
|
if (g_dbglevel >= DBG_ERROR) DbpString("Failed to allocate memory");
|
||||||
|
reply_ng(CMD_HF_THINFILM_READ, PM3_EMALLOC, NULL, 0);
|
||||||
|
hf_field_off();
|
||||||
|
set_tracing(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// power on and listen for answer.
|
// power on and listen for answer.
|
||||||
bool status = GetIso14443aAnswerFromTag_Thinfilm(buf, 36, &len);
|
bool status = GetIso14443aAnswerFromTag_Thinfilm(buf, 36, &len);
|
||||||
|
|||||||
Reference in new issue
Block a user