swapped from bigbuf malloc calls to calloc calls on device side. Now all allocations should start from a known state of memory
Some checks failed
Windows Build and Test / wsl (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
MacOS Build and Test / macos-make (push) Has been cancelled
MacOS Build and Test / macos-make-btaddon (push) Has been cancelled
MacOS Build and Test / macos-cmake (push) Has been cancelled
Windows Build and Test / proxspace (push) Has been cancelled
Ubuntu Build and Test / ubuntu-make (push) Has been cancelled
Ubuntu Build and Test / ubuntu-make-btaddon (push) Has been cancelled
Ubuntu Build and Test / ubuntu-cmake (push) Has been cancelled

This commit is contained in:
iceman1001 2025-08-20 16:23:36 +02:00
commit 6ee974b935
20 changed files with 58 additions and 54 deletions

View file

@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
## [unreleased][unreleased] ## [unreleased][unreleased]
- Changed from Bigbuf malloc to Bigbuf calloc calls on device side (@iceman1001)
- Added `lf t55xx view` - now viewing of T55XX dump files is possible (@iceman1001) - Added `lf t55xx view` - now viewing of T55XX dump files is possible (@iceman1001)
- Fixed `lf indala cone` - now writing the right bits when using `--fc` and `--cn` - Fixed `lf indala cone` - now writing the right bits when using `--fc` and `--cn`
- Changed readline hack logic for async dbg msg to be ready for readline 8.3 (@doegox) - Changed readline hack logic for async dbg msg to be ready for readline 8.3 (@doegox)

View file

@ -354,7 +354,7 @@ int emlGet(uint8_t *out, uint32_t offset, uint32_t length) {
tosend_t *get_tosend(void) { tosend_t *get_tosend(void) {
if (s_toSend.buf == NULL) { if (s_toSend.buf == NULL) {
s_toSend.buf = BigBuf_malloc(TOSEND_BUFFER_SIZE); s_toSend.buf = BigBuf_calloc(TOSEND_BUFFER_SIZE);
} }
return &s_toSend; return &s_toSend;
} }
@ -377,8 +377,9 @@ void tosend_stuffbit(int b) {
s_toSend.bit = 0; s_toSend.bit = 0;
} }
if (b) if (b) {
s_toSend.buf[s_toSend.max] |= (1 << (7 - s_toSend.bit)); s_toSend.buf[s_toSend.max] |= (1 << (7 - s_toSend.bit));
}
s_toSend.bit++; s_toSend.bit++;
@ -389,15 +390,14 @@ void tosend_stuffbit(int b) {
dmabuf16_t *get_dma16(void) { dmabuf16_t *get_dma16(void) {
if (s_dma_16.buf == NULL) { if (s_dma_16.buf == NULL) {
s_dma_16.buf = (uint16_t *)BigBuf_malloc(DMA_BUFFER_SIZE * sizeof(uint16_t)); s_dma_16.buf = (uint16_t *)BigBuf_calloc(DMA_BUFFER_SIZE * sizeof(uint16_t));
} }
return &s_dma_16; return &s_dma_16;
} }
dmabuf8_t *get_dma8(void) { dmabuf8_t *get_dma8(void) {
if (s_dma_8.buf == NULL) if (s_dma_8.buf == NULL) {
s_dma_8.buf = BigBuf_malloc(DMA_BUFFER_SIZE); s_dma_8.buf = BigBuf_calloc(DMA_BUFFER_SIZE);
}
return &s_dma_8; return &s_dma_8;
} }

View file

@ -63,18 +63,18 @@ static void RAMFUNC SniffAndStore(uint8_t param) {
set_tracing(true); set_tracing(true);
// Array to store the authpwds // Array to store the authpwds
uint8_t *capturedPwds = BigBuf_malloc(4 * MAX_PWDS_PER_SESSION); uint8_t *capturedPwds = BigBuf_calloc(4 * MAX_PWDS_PER_SESSION);
// The command (reader -> tag) that we're receiving. // The command (reader -> tag) that we're receiving.
uint8_t *receivedCmd = BigBuf_malloc(MAX_FRAME_SIZE); uint8_t *receivedCmd = BigBuf_calloc(MAX_FRAME_SIZE);
uint8_t *receivedCmdPar = BigBuf_malloc(MAX_PARITY_SIZE); uint8_t *receivedCmdPar = BigBuf_calloc(MAX_PARITY_SIZE);
// The response (tag -> reader) that we're receiving. // The response (tag -> reader) that we're receiving.
uint8_t *receivedResp = BigBuf_malloc(MAX_FRAME_SIZE); uint8_t *receivedResp = BigBuf_calloc(MAX_FRAME_SIZE);
uint8_t *receivedRespPar = BigBuf_malloc(MAX_PARITY_SIZE); uint8_t *receivedRespPar = BigBuf_calloc(MAX_PARITY_SIZE);
// The DMA buffer, used to stream samples from the FPGA // The DMA buffer, used to stream samples from the FPGA
uint8_t *dmaBuf = BigBuf_malloc(DMA_BUFFER_SIZE); uint8_t *dmaBuf = BigBuf_calloc(DMA_BUFFER_SIZE);
uint8_t *data = dmaBuf; uint8_t *data = dmaBuf;
uint8_t previous_data = 0; uint8_t previous_data = 0;

View file

@ -250,7 +250,7 @@ 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_malloc(size); uint8_t *mem = BigBuf_calloc(size);
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) {
@ -292,7 +292,7 @@ static void ReadLastTagFromFlash(void) {
DbprintfEx(FLAG_NEWLINE, "Button HELD ! Using LAST Known TAG for Simulation..."); DbprintfEx(FLAG_NEWLINE, "Button HELD ! Using LAST Known TAG for Simulation...");
cjSetCursLeft(); cjSetCursLeft();
uint8_t *mem = BigBuf_malloc(size); uint8_t *mem = BigBuf_calloc(size);
// 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);
@ -445,11 +445,11 @@ void RunMod(void) {
}; };
// Can remember something like that in case of Bigbuf // Can remember something like that in case of Bigbuf
keyBlock = BigBuf_malloc(ARRAYLEN(mfKeys) * 6); keyBlock = BigBuf_calloc(ARRAYLEN(mfKeys) * MF_KEY_LENGTH);
int mfKeysCnt = ARRAYLEN(mfKeys); int mfKeysCnt = ARRAYLEN(mfKeys);
for (int mfKeyCounter = 0; mfKeyCounter < mfKeysCnt; mfKeyCounter++) { for (int mfKeyCounter = 0; mfKeyCounter < mfKeysCnt; mfKeyCounter++) {
num_to_bytes(mfKeys[mfKeyCounter], 6, (uint8_t *)(keyBlock + mfKeyCounter * 6)); num_to_bytes(mfKeys[mfKeyCounter], MF_KEY_LENGTH, (uint8_t *)(keyBlock + (mfKeyCounter * MF_KEY_LENGTH)));
} }
// TODO : remember why we actually had need to initialize this array in such specific case // TODO : remember why we actually had need to initialize this array in such specific case

View file

@ -238,7 +238,7 @@ static int reader_attack_mode(void) {
BigBuf_free(); BigBuf_free();
uint16_t mac_response_len = 0; uint16_t mac_response_len = 0;
uint8_t *mac_responses = BigBuf_malloc(MAC_RESPONSES_SIZE); uint8_t *mac_responses = BigBuf_calloc(MAC_RESPONSES_SIZE);
iclass_simulate(ICLASS_SIM_MODE_READER_ATTACK, NUM_CSNS, false, csns, mac_responses, &mac_response_len); iclass_simulate(ICLASS_SIM_MODE_READER_ATTACK, NUM_CSNS, false, csns, mac_responses, &mac_response_len);
@ -250,7 +250,7 @@ static int reader_attack_mode(void) {
size_t dumplen = NUM_CSNS * 24; size_t dumplen = NUM_CSNS * 24;
uint8_t *dump = BigBuf_malloc(dumplen); uint8_t *dump = BigBuf_calloc(dumplen);
if (dump == false) { if (dump == false) {
Dbprintf("Failed to allocate memory"); Dbprintf("Failed to allocate memory");
return PM3_EMALLOC; return PM3_EMALLOC;
@ -305,6 +305,7 @@ static int reader_dump_mode(void) {
BigBuf_free(); BigBuf_free();
uint8_t *card_data = BigBuf_malloc(ICLASS_16KS_SIZE); uint8_t *card_data = BigBuf_malloc(ICLASS_16KS_SIZE);
// Don't use calloc since we set allocated memory to 0xFF's
memset(card_data, 0xFF, ICLASS_16KS_SIZE); memset(card_data, 0xFF, ICLASS_16KS_SIZE);
if (BUTTON_PRESS()) { if (BUTTON_PRESS()) {
@ -442,6 +443,7 @@ static int dump_sim_mode(void) {
BigBuf_free(); BigBuf_free();
uint8_t *card_data = BigBuf_malloc(ICLASS_16KS_SIZE); uint8_t *card_data = BigBuf_malloc(ICLASS_16KS_SIZE);
// Don't use calloc since we set allocated memory to 0xFF's
memset(card_data, 0xFF, ICLASS_16KS_SIZE); memset(card_data, 0xFF, ICLASS_16KS_SIZE);
if (BUTTON_PRESS()) { if (BUTTON_PRESS()) {

View file

@ -247,7 +247,7 @@ void RunMod(void) {
// usb_disable(); // usb_disable();
// Allocate dictionary buffer // Allocate dictionary buffer
uint64_t *const mfcKeys = (uint64_t *)BigBuf_malloc( uint64_t *const mfcKeys = (uint64_t *)BigBuf_calloc(
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));

View file

@ -199,7 +199,7 @@ static uint32_t IceIOdemod(void) {
size_t size = MIN(12000, BigBuf_max_traceLen()); size_t size = MIN(12000, BigBuf_max_traceLen());
// uint8_t *dest = BigBuf_malloc(size); // uint8_t *dest = BigBuf_calloc(size);
uint8_t *dest = BigBuf_get_addr(); uint8_t *dest = BigBuf_get_addr();
//fskdemod and get start index //fskdemod and get start index
@ -243,7 +243,7 @@ static uint32_t IceHIDDemod(void) {
// large enough to catch 2 sequences of largest format // large enough to catch 2 sequences of largest format
// size_t size = 50 * 128 * 2; // 12800 bytes // size_t size = 50 * 128 * 2; // 12800 bytes
size_t size = MIN(12800, BigBuf_max_traceLen()); size_t size = MIN(12800, BigBuf_max_traceLen());
//uint8_t *dest = BigBuf_malloc(size); //uint8_t *dest = BigBuf_calloc(size);
uint8_t *dest = BigBuf_get_addr(); uint8_t *dest = BigBuf_get_addr();
// FSK demodulator // FSK demodulator

View file

@ -103,9 +103,9 @@ static bool get_input_data_from_file(uint32_t *tag, char *inputfile) {
if (exists_in_spiffs(inputfile)) { if (exists_in_spiffs(inputfile)) {
uint32_t size = size_in_spiffs(inputfile); uint32_t size = size_in_spiffs(inputfile);
uint8_t *mem = BigBuf_malloc(size); uint8_t *mem = BigBuf_calloc(size);
Dbprintf(_YELLOW_("found input file %s"), inputfile); Dbprintf("found input file `" _YELLOW_("%s") "`", inputfile);
rdv40_spiffs_read_as_filetype(inputfile, mem, size, RDV40_SPIFFS_SAFETY_SAFE); rdv40_spiffs_read_as_filetype(inputfile, mem, size, RDV40_SPIFFS_SAFETY_SAFE);

View file

@ -334,7 +334,7 @@ void cmac(const desfirekey_t key, uint8_t *ivect, const uint8_t *data, size_t le
return; return;
} }
uint8_t *buffer = BigBuf_malloc(padded_data_length(len, kbs)); uint8_t *buffer = BigBuf_calloc(padded_data_length(len, kbs));
memcpy(buffer, data, len); memcpy(buffer, data, len);

View file

@ -497,7 +497,7 @@ static void iso18092_setup(uint8_t fpga_minor_mode) {
BigBuf_Clear_ext(false); BigBuf_Clear_ext(false);
// Initialize Demod and Uart structs // Initialize Demod and Uart structs
// DemodInit(BigBuf_malloc(MAX_FRAME_SIZE)); // DemodInit(BigBuf_calloc(MAX_FRAME_SIZE));
FelicaFrameinit(BigBuf_calloc(FELICA_MAX_FRAME_SIZE)); FelicaFrameinit(BigBuf_calloc(FELICA_MAX_FRAME_SIZE));
felica_nexttransfertime = 2 * DELAY_ARM2AIR_AS_READER; // 418 felica_nexttransfertime = 2 * DELAY_ARM2AIR_AS_READER; // 418

View file

@ -523,10 +523,11 @@ void FpgaDownloadAndGo(int bitstream_target) {
lz4_stream_t compressed_fpga_stream; lz4_stream_t compressed_fpga_stream;
LZ4_streamDecode_t lz4StreamDecode_body = {{ 0 }}; LZ4_streamDecode_t lz4StreamDecode_body = {{ 0 }};
compressed_fpga_stream.lz4StreamDecode = &lz4StreamDecode_body; compressed_fpga_stream.lz4StreamDecode = &lz4StreamDecode_body;
uint8_t *output_buffer = BigBuf_malloc(FPGA_RING_BUFFER_BYTES); uint8_t *output_buffer = BigBuf_calloc(FPGA_RING_BUFFER_BYTES);
if (!reset_fpga_stream(bitstream_target, &compressed_fpga_stream, output_buffer)) if (reset_fpga_stream(bitstream_target, &compressed_fpga_stream, output_buffer) == false) {
return; return;
}
uint32_t bitstream_length; uint32_t bitstream_length;
if (bitparse_find_section(bitstream_target, 'e', &bitstream_length, &compressed_fpga_stream, output_buffer)) { if (bitparse_find_section(bitstream_target, 'e', &bitstream_length, &compressed_fpga_stream, output_buffer)) {

View file

@ -26,7 +26,7 @@
#include "nprintf.h" #include "nprintf.h"
#include "BigBuf.h" #include "BigBuf.h"
#define malloc(X) BigBuf_malloc(X) #define malloc(X) BigBuf_calloc(X)
#define free(X) #define free(X)
#if !defined(WEAK) #if !defined(WEAK)

View file

@ -107,7 +107,7 @@ int HfSniff(uint32_t samplesToSkip, uint32_t triggersToSkip, uint16_t *len, uint
SpinDelay(100); SpinDelay(100);
*len = BigBuf_max_traceLen(); *len = BigBuf_max_traceLen();
uint8_t *mem = BigBuf_malloc(*len); uint8_t *mem = BigBuf_calloc(*len);
uint32_t trigger_cnt = 0; uint32_t trigger_cnt = 0;
uint16_t r = 0, interval = 0; uint16_t r = 0, interval = 0;

View file

@ -917,8 +917,9 @@ send:
LEDsoff(); LEDsoff();
if (button_pressed) if (button_pressed) {
DbpString("button pressed"); DbpString("button pressed");
}
return button_pressed; return button_pressed;
} }

View file

@ -786,14 +786,14 @@ void SimulateIso14443bTag(const uint8_t *pupi) {
// prepare "ATQB" tag answer (encoded): // prepare "ATQB" tag answer (encoded):
CodeIso14443bAsTag(respATQB, sizeof(respATQB)); CodeIso14443bAsTag(respATQB, sizeof(respATQB));
uint8_t *encodedATQB = BigBuf_malloc(ts->max); uint8_t *encodedATQB = BigBuf_calloc(ts->max);
uint16_t encodedATQBLen = ts->max; uint16_t encodedATQBLen = ts->max;
memcpy(encodedATQB, ts->buf, ts->max); memcpy(encodedATQB, ts->buf, ts->max);
// prepare "OK" tag answer (encoded): // prepare "OK" tag answer (encoded):
CodeIso14443bAsTag(respOK, sizeof(respOK)); CodeIso14443bAsTag(respOK, sizeof(respOK));
uint8_t *encodedOK = BigBuf_malloc(ts->max); uint8_t *encodedOK = BigBuf_calloc(ts->max);
uint16_t encodedOKLen = ts->max; uint16_t encodedOKLen = ts->max;
memcpy(encodedOK, ts->buf, ts->max); memcpy(encodedOK, ts->buf, ts->max);
@ -988,18 +988,18 @@ void Simulate_iso14443b_srx_tag(uint8_t *uid) {
tosend_t *ts = get_tosend(); tosend_t *ts = get_tosend();
uint8_t *receivedCmd = BigBuf_malloc(MAX_FRAME_SIZE); uint8_t *receivedCmd = BigBuf_calloc(MAX_FRAME_SIZE);
// prepare "ATQB" tag answer (encoded): // prepare "ATQB" tag answer (encoded):
CodeIso14443bAsTag(respATQB, sizeof(respATQB)); CodeIso14443bAsTag(respATQB, sizeof(respATQB));
uint8_t *encodedATQB = BigBuf_malloc(ts->max); uint8_t *encodedATQB = BigBuf_calloc(ts->max);
uint16_t encodedATQBLen = ts->max; uint16_t encodedATQBLen = ts->max;
memcpy(encodedATQB, ts->buf, ts->max); memcpy(encodedATQB, ts->buf, ts->max);
// prepare "OK" tag answer (encoded): // prepare "OK" tag answer (encoded):
CodeIso14443bAsTag(respOK, sizeof(respOK)); CodeIso14443bAsTag(respOK, sizeof(respOK));
uint8_t *encodedOK = BigBuf_malloc(ts->max); uint8_t *encodedOK = BigBuf_calloc(ts->max);
uint16_t encodedOKLen = ts->max; uint16_t encodedOKLen = ts->max;
memcpy(encodedOK, ts->buf, ts->max); memcpy(encodedOK, ts->buf, ts->max);
@ -2405,8 +2405,8 @@ void SniffIso14443b(void) {
uint8_t ua_buf[MAX_FRAME_SIZE] = {0}; uint8_t ua_buf[MAX_FRAME_SIZE] = {0};
Uart14bInit(ua_buf); Uart14bInit(ua_buf);
//Demod14bInit(BigBuf_malloc(MAX_FRAME_SIZE), MAX_FRAME_SIZE); //Demod14bInit(BigBuf_calloc(MAX_FRAME_SIZE));
//Uart14bInit(BigBuf_malloc(MAX_FRAME_SIZE)); //Uart14bInit(BigBuf_calloc(MAX_FRAME_SIZE));
// Set FPGA in the appropriate mode // Set FPGA in the appropriate mode
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER | FPGA_HF_READER_SUBCARRIER_848_KHZ | FPGA_HF_READER_MODE_SNIFF_IQ); FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER | FPGA_HF_READER_SUBCARRIER_848_KHZ | FPGA_HF_READER_MODE_SNIFF_IQ);

View file

@ -180,8 +180,7 @@ static void CodeIso15693AsReaderEOF(void) {
static int get_uid_slix(uint32_t start_time, uint32_t *eof_time, uint8_t *uid) { static int get_uid_slix(uint32_t start_time, uint32_t *eof_time, uint8_t *uid) {
uint8_t *answer = BigBuf_malloc(ISO15693_MAX_RESPONSE_LENGTH); uint8_t *answer = BigBuf_calloc(ISO15693_MAX_RESPONSE_LENGTH);
memset(answer, 0x00, ISO15693_MAX_RESPONSE_LENGTH);
start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER;
@ -1484,7 +1483,7 @@ int GetIso15693CommandFromReader(uint8_t *received, size_t max_len, uint32_t *eo
bool gotFrame = false; bool gotFrame = false;
// the decoder data structure // the decoder data structure
DecodeReader_t *dr = (DecodeReader_t *)BigBuf_malloc(sizeof(DecodeReader_t)); DecodeReader_t *dr = (DecodeReader_t *)BigBuf_calloc(sizeof(DecodeReader_t));
DecodeReaderInit(dr, received, max_len, 0, NULL); DecodeReaderInit(dr, received, max_len, 0, NULL);
// wait for last transfer to complete // wait for last transfer to complete
@ -1589,7 +1588,7 @@ void AcquireRawAdcSamplesIso15693(void) {
LED_A_ON(); LED_A_ON();
uint8_t *dest = BigBuf_malloc(4000); uint8_t *dest = BigBuf_calloc(4096);
// switch field on // switch field on
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER); FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER);
@ -2031,7 +2030,7 @@ void ReaderIso15693(iso15_card_select_t *p_card) {
LED_A_ON(); LED_A_ON();
set_tracing(true); set_tracing(true);
uint8_t *answer = BigBuf_malloc(ISO15693_MAX_RESPONSE_LENGTH); uint8_t *answer = BigBuf_calloc(ISO15693_MAX_RESPONSE_LENGTH);
memset(answer, 0x00, ISO15693_MAX_RESPONSE_LENGTH); memset(answer, 0x00, ISO15693_MAX_RESPONSE_LENGTH);
// FIRST WE RUN AN INVENTORY TO GET THE TAG UID // FIRST WE RUN AN INVENTORY TO GET THE TAG UID

View file

@ -340,7 +340,7 @@ t55xx_configurations_t *getT55xxConfig(void) {
void loadT55xxConfig(void) { void loadT55xxConfig(void) {
#ifdef WITH_FLASH #ifdef WITH_FLASH
uint8_t *buf = BigBuf_malloc(T55XX_CONFIG_LEN); uint8_t *buf = BigBuf_calloc(T55XX_CONFIG_LEN);
uint32_t size = 0; uint32_t size = 0;
if (exists_in_spiffs(T55XX_CONFIG_FILE)) { if (exists_in_spiffs(T55XX_CONFIG_FILE)) {
@ -2912,7 +2912,7 @@ void Cotag(uint32_t arg0, bool ledcontrol) {
break; break;
} }
case 1: { case 1: {
uint8_t *dest = BigBuf_malloc(COTAG_BITS); uint8_t *dest = BigBuf_calloc(COTAG_BITS);
uint16_t bits = doCotagAcquisitionManchester(dest, COTAG_BITS); uint16_t bits = doCotagAcquisitionManchester(dest, COTAG_BITS);
reply_ng(CMD_LF_COTAG_READ, PM3_SUCCESS, dest, bits); reply_ng(CMD_LF_COTAG_READ, PM3_SUCCESS, dest, bits);
break; break;

View file

@ -149,7 +149,7 @@ void initSampleBufferEx(uint32_t *sample_size, bool use_malloc) {
data.buffer = BigBuf_get_addr(); data.buffer = BigBuf_get_addr();
} else { } else {
*sample_size = MIN(*sample_size, BigBuf_max_traceLen()); *sample_size = MIN(*sample_size, BigBuf_max_traceLen());
data.buffer = BigBuf_malloc(*sample_size); data.buffer = BigBuf_calloc(*sample_size);
} }
} else { } else {
@ -669,7 +669,7 @@ void doT55x7Acquisition(size_t sample_size, bool ledcontrol) {
void doCotagAcquisition(void) { void doCotagAcquisition(void) {
uint16_t bufsize = BigBuf_max_traceLen(); uint16_t bufsize = BigBuf_max_traceLen();
uint8_t *dest = BigBuf_malloc(bufsize); uint8_t *dest = BigBuf_calloc(bufsize);
dest[0] = 0; dest[0] = 0;

View file

@ -2252,7 +2252,7 @@ OUT:
bar |= ((uint16_t)(found[m] & 1) << j++); bar |= ((uint16_t)(found[m] & 1) << j++);
} }
uint8_t *tmp = BigBuf_malloc(480 + 10); uint8_t *tmp = BigBuf_calloc(480 + 10);
memcpy(tmp, k_sector, sectorcnt * sizeof(sector_t)); memcpy(tmp, k_sector, sectorcnt * sizeof(sector_t));
num_to_bytes(foo, 8, tmp + 480); num_to_bytes(foo, 8, tmp + 480);
tmp[488] = bar & 0xFF; tmp[488] = bar & 0xFF;
@ -2409,7 +2409,7 @@ void MifareChkKeys_file(uint8_t *fn) {
int changed = rdv40_spiffs_lazy_mount(); int changed = rdv40_spiffs_lazy_mount();
uint32_t size = size_in_spiffs((char *)fn); uint32_t size = size_in_spiffs((char *)fn);
uint8_t *mem = BigBuf_malloc(size); uint8_t *mem = BigBuf_calloc(size);
rdv40_spiffs_read_as_filetype((char *)fn, mem, size, RDV40_SPIFFS_SAFETY_SAFE); rdv40_spiffs_read_as_filetype((char *)fn, mem, size, RDV40_SPIFFS_SAFETY_SAFE);
@ -3609,13 +3609,13 @@ void MifareG4ReadBlk(uint8_t blockno, uint8_t *pwd, uint8_t workFlags) {
int res = 0; int res = 0;
int retval = PM3_SUCCESS; int retval = PM3_SUCCESS;
uint8_t *buf = BigBuf_malloc(PM3_CMD_DATA_SIZE); uint8_t *buf = BigBuf_calloc(PM3_CMD_DATA_SIZE);
if (buf == NULL) { if (buf == NULL) {
retval = PM3_EMALLOC; retval = PM3_EMALLOC;
goto OUT; goto OUT;
} }
uint8_t *par = BigBuf_malloc(MAX_PARITY_SIZE); uint8_t *par = BigBuf_calloc(MAX_PARITY_SIZE);
if (par == NULL) { if (par == NULL) {
retval = PM3_EMALLOC; retval = PM3_EMALLOC;
goto OUT; goto OUT;
@ -3685,7 +3685,7 @@ void MifareG4WriteBlk(uint8_t blockno, uint8_t *pwd, uint8_t *data, uint8_t work
int res = 0; int res = 0;
int retval = PM3_SUCCESS; int retval = PM3_SUCCESS;
uint8_t *buf = BigBuf_malloc(PM3_CMD_DATA_SIZE); uint8_t *buf = BigBuf_calloc(PM3_CMD_DATA_SIZE);
if (buf == NULL) { if (buf == NULL) {
retval = PM3_EMALLOC; retval = PM3_EMALLOC;
goto OUT; goto OUT;
@ -3697,7 +3697,7 @@ void MifareG4WriteBlk(uint8_t blockno, uint8_t *pwd, uint8_t *data, uint8_t work
goto OUT; goto OUT;
} }
uint8_t *par = BigBuf_malloc(MAX_PARITY_SIZE); uint8_t *par = BigBuf_calloc(MAX_PARITY_SIZE);
if (par == NULL) { if (par == NULL) {
retval = PM3_EMALLOC; retval = PM3_EMALLOC;
goto OUT; goto OUT;

View file

@ -459,7 +459,7 @@ bool MifareSimInit(uint16_t flags, uint8_t *uid, uint16_t atqa, uint8_t sak, tag
// 53 * 8 data bits, 53 * 1 parity bits, 18 start bits, 18 stop bits, 18 correction bits -> need 571 bytes buffer // 53 * 8 data bits, 53 * 1 parity bits, 18 start bits, 18 stop bits, 18 correction bits -> need 571 bytes buffer
#define ALLOCATED_TAG_MODULATION_BUFFER_SIZE 571 #define ALLOCATED_TAG_MODULATION_BUFFER_SIZE 571
uint8_t *free_buffer = BigBuf_malloc(ALLOCATED_TAG_MODULATION_BUFFER_SIZE); uint8_t *free_buffer = BigBuf_calloc(ALLOCATED_TAG_MODULATION_BUFFER_SIZE);
// modulation buffer pointer and current buffer free space size // modulation buffer pointer and current buffer free space size
uint8_t *free_buffer_pointer = free_buffer; uint8_t *free_buffer_pointer = free_buffer;
size_t free_buffer_size = ALLOCATED_TAG_MODULATION_BUFFER_SIZE; size_t free_buffer_size = ALLOCATED_TAG_MODULATION_BUFFER_SIZE;