unify text - step 1

This commit is contained in:
iceman1001
2025-03-25 10:12:16 +01:00
parent 090f31d0a7
commit 875b3c44b4
40 changed files with 167 additions and 128 deletions
+3 -1
View File
@@ -70,7 +70,9 @@ void RunMod(void) {
FpgaDownloadAndGo(FPGA_BITSTREAM_HF_15);
iso15_tag_t *tag = (iso15_tag_t *) BigBuf_get_EM_addr();
if (tag == NULL) return;
if (tag == NULL) {
return;
}
uint8_t cmd[8] = {0};
int res;
+1 -1
View File
@@ -252,7 +252,7 @@ static int reader_attack_mode(void) {
uint8_t *dump = BigBuf_malloc(dumplen);
if (dump == false) {
Dbprintf("failed to allocate memory");
Dbprintf("Failed to allocate memory");
return PM3_EMALLOC;
}
+4 -2
View File
@@ -69,16 +69,18 @@ static void save_dump_to_file(legic_card_select_t *p_card) {
// legic functions puts it memory in Emulator reserved memory.
uint8_t *mem = BigBuf_get_EM_addr();
char *preferredName = (char *)BigBuf_malloc(30);
char *preferredName = (char *)BigBuf_calloc(30);
if (preferredName == NULL) {
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Failed to allocate memory");
goto OUT;
}
sprintf(preferredName, "hf-legic-%02X%02X%02X%02X-dump", p_card->uid[0], p_card->uid[1], p_card->uid[2], p_card->uid[3]);
uint16_t preferredNameLen = strlen(preferredName);
char *filename = (char *)BigBuf_malloc(preferredNameLen + 4 + 1 + 10);
char *filename = (char *)BigBuf_calloc(preferredNameLen + 4 + 1 + 10);
if (filename == NULL) {
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Failed to allocate memory");
goto OUT;
}
+1 -1
View File
@@ -201,7 +201,7 @@ void RunMod(void) {
// available after filling the trace buffer.
char *filename = (char *)BigBuf_calloc(64);
if (filename == NULL) {
Dbprintf("failed to allocate memory");
Dbprintf("Failed to allocate memory");
return;
}
// Read the config file. Size is limited to defined value so as not to consume
+2 -1
View File
@@ -2696,7 +2696,7 @@ static void PacketReceived(PacketCommandNG *packet) {
uint8_t *buff = BigBuf_malloc(size);
if (buff == NULL) {
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Could not allocate buffer");
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Failed to allocate memory");
// Trigger a finish downloading signal with an PM3_EMALLOC
reply_ng(CMD_SPIFFS_DOWNLOAD, PM3_EMALLOC, NULL, 0);
} else {
@@ -2826,6 +2826,7 @@ static void PacketReceived(PacketCommandNG *packet) {
uint8_t *em = BigBuf_get_EM_addr();
if (em == NULL) {
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Failed to allocate memory");
reply_ng(CMD_SPIFFS_ELOAD, PM3_EMALLOC, NULL, 0);
LED_B_OFF();
break;
+3 -1
View File
@@ -185,7 +185,9 @@ void FpgaSetupSsc(uint16_t fpga_mode) {
// ourselves, not to another buffer).
//-----------------------------------------------------------------------------
bool FpgaSetupSscDma(uint8_t *buf, uint16_t len) {
if (buf == NULL) return false;
if (buf == NULL) {
return false;
}
FpgaDisableSscDma();
AT91C_BASE_PDC_SSC->PDC_RPR = (uint32_t) buf; // transfer to this memory address
-1
View File
@@ -783,7 +783,6 @@ bool GetATR(smart_card_atr_t *card_ptr, bool verbose) {
return false;
}
card_ptr->atr_len = 0;
memset(card_ptr->atr, 0, sizeof(card_ptr->atr));
+2 -1
View File
@@ -167,9 +167,10 @@ int CmdSmartRaw(const uint8_t prepend, const uint8_t *data, int dlen, uint8_t *o
smart_card_raw_t *payload = (smart_card_raw_t *)BigBuf_calloc(sizeof(smart_card_raw_t) + dlen);
if (payload == NULL) {
Dbprintf("failed to allocate memory");
Dbprintf("Failed to allocate memory");
return PM3_EMALLOC;
}
payload->len = dlen;
memcpy(payload->data, data, dlen);
+2 -2
View File
@@ -1664,9 +1664,9 @@ void iClass_Dump(uint8_t *msg) {
iclass_auth_req_t *req = &cmd->req;
bool shallow_mod = req->shallow_mod;
uint8_t *dataout = BigBuf_malloc(ICLASS_16KS_SIZE);
uint8_t *dataout = BigBuf_calloc(ICLASS_16KS_SIZE);
if (dataout == NULL) {
DbpString("fail to allocate memory");
DbpString("Failed to allocate memory");
if (req->send_reply) {
reply_ng(CMD_HF_ICLASS_DUMP, PM3_EMALLOC, NULL, 0);
}
+6 -1
View File
@@ -2407,7 +2407,10 @@ int EmSendCmdEx(uint8_t *resp, uint16_t respLen, bool collision) {
}
int EmSendPrecompiledCmd(tag_response_info_t *p_response) {
if (p_response == NULL) return 0;
if (p_response == NULL) {
return 0;
}
int ret = EmSendCmd14443aRaw(p_response->modulation, p_response->modulation_n);
// do the tracing for the previous reader request and this tag answer:
GetParity(p_response->response, p_response->response_n, parity_array);
@@ -4032,12 +4035,14 @@ void SimulateIso14443aTagAID(uint8_t tagType, uint16_t flags, uint8_t *uid,
reply_ng(CMD_HF_MIFARE_SIMULATE, PM3_EMALLOC, NULL, 0);
return;
}
uint8_t *dynamic_modulation_buffer2 = BigBuf_calloc(DYNAMIC_MODULATION_BUFFER2_SIZE);
if (dynamic_modulation_buffer2 == NULL) {
BigBuf_free_keep_EM();
reply_ng(CMD_HF_MIFARE_SIMULATE, PM3_EMALLOC, NULL, 0);
return;
}
tag_response_info_t dynamic_response_info = {
.response = dynamic_response_buffer2,
.response_n = 0,
+1
View File
@@ -1336,6 +1336,7 @@ static int Get14443bAnswerFromTag(uint8_t *response, uint16_t max_len, uint32_t
// The DMA buffer, used to stream samples from the FPGA
dmabuf16_t *dma = get_dma16();
if (dma == NULL) {
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Failed to allocate memory");
return PM3_EMALLOC;
}
+1 -1
View File
@@ -2129,7 +2129,7 @@ void SimTagIso15693(const uint8_t *uid, uint8_t block_size) {
iso15_tag_t *tag = (iso15_tag_t *) BigBuf_get_EM_addr();
if (tag == NULL) {
Dbprintf("Can't allocate emulator memory");
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Failed to allocate memory");
reply_ng(CMD_HF_ISO15693_SIMULATE, PM3_EFAILED, NULL, 0);
return;
}
+2 -1
View File
@@ -739,8 +739,9 @@ void doCotagAcquisition(void) {
uint16_t doCotagAcquisitionManchester(uint8_t *dest, uint16_t destlen) {
if (dest == NULL)
if (dest == NULL) {
return 0;
}
dest[0] = 0;
+2 -2
View File
@@ -398,9 +398,9 @@ void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain)
bool useKey = (arg2 == 1); // UL_C
bool usePwd = (arg2 == 2); // UL_EV1/NTAG
uint32_t countblocks = 0;
uint8_t *dataout = BigBuf_malloc(CARD_MEMORY_SIZE);
uint8_t *dataout = BigBuf_calloc(CARD_MEMORY_SIZE);
if (dataout == NULL) {
Dbprintf("out of memory");
Dbprintf("Failed to allocate memory");
OnError(1);
return;
}
+4 -2
View File
@@ -104,11 +104,13 @@ kvsprintf(char const *fmt, void *arg, int radix, va_list ap) {
num = 0;
d = (char *) arg;
if (fmt == NULL)
if (fmt == NULL) {
fmt = "(fmt null)\n";
}
if (radix < 2 || radix > 36)
if (radix < 2 || radix > 36) {
radix = 10;
}
for (;;) {
padc = ' ';
+3 -6
View File
@@ -261,20 +261,17 @@ int sam_get_version(void) {
} else {
uint8_t *sam_response_an = sam_find_asn1_node(response + 5, 0x8a);
if (sam_response_an == NULL) {
if (g_dbglevel >= DBG_ERROR)
DbpString("SAM get response failed");
if (g_dbglevel >= DBG_ERROR) DbpString("SAM get response failed");
goto error;
}
uint8_t *sam_version_an = sam_find_asn1_node(sam_response_an, 0x80);
if (sam_version_an == NULL) {
if (g_dbglevel >= DBG_ERROR)
DbpString("SAM get version failed");
if (g_dbglevel >= DBG_ERROR) DbpString("SAM get version failed");
goto error;
}
uint8_t *sam_build_an = sam_find_asn1_node(sam_response_an, 0x81);
if (sam_build_an == NULL) {
if (g_dbglevel >= DBG_ERROR)
DbpString("SAM get firmware ID failed");
if (g_dbglevel >= DBG_ERROR) DbpString("SAM get firmware ID failed");
goto error;
}
if (g_dbglevel >= DBG_INFO) {
+2 -2
View File
@@ -131,8 +131,8 @@ static int sam_send_request_iso14a(const uint8_t *const request, const uint8_t r
DbpString("start sam_send_request_iso14a");
}
uint8_t *buf1 = BigBuf_malloc(ISO7816_MAX_FRAME);
uint8_t *buf2 = BigBuf_malloc(ISO7816_MAX_FRAME);
uint8_t *buf1 = BigBuf_calloc(ISO7816_MAX_FRAME);
uint8_t *buf2 = BigBuf_calloc(ISO7816_MAX_FRAME);
if (buf1 == NULL || buf2 == NULL) {
res = PM3_EMALLOC;
goto out;
+15 -7
View File
@@ -84,16 +84,19 @@ static const char *jsonStrGet(json_t *data, const char *name) {
json_t *jstr;
jstr = json_object_get(data, name);
if (jstr == NULL)
if (jstr == NULL) {
return NULL;
}
if (!json_is_string(jstr)) {
PrintAndLogEx(ERR, "`%s` is not a string", name);
return NULL;
}
const char *cstr = json_string_value(jstr);
if (strlen(cstr) == 0)
if (strlen(cstr) == 0) {
return NULL;
}
return cstr;
}
@@ -125,17 +128,20 @@ int PrintAIDDescription(json_t *xroot, char *aid, bool verbose) {
int retval = PM3_SUCCESS;
json_t *root = xroot;
if (root == NULL)
if (root == NULL) {
root = AIDSearchInit(verbose);
if (root == NULL)
}
if (root == NULL) {
goto out;
}
json_t *elm = NULL;
size_t maxaidlen = 0;
for (size_t elmindx = 0; elmindx < json_array_size(root); elmindx++) {
json_t *data = AIDSearchGetElm(root, elmindx);
if (data == NULL)
if (data == NULL) {
continue;
}
const char *dictaid = jsonStrGet(data, "AID");
if (aidCompare(aid, dictaid)) { // dictaid may be less length than requested aid
if (maxaidlen < strlen(dictaid) && strlen(dictaid) <= strlen(aid)) {
@@ -145,8 +151,9 @@ int PrintAIDDescription(json_t *xroot, char *aid, bool verbose) {
}
}
if (elm == NULL)
if (elm == NULL) {
goto out;
}
// print here
const char *vaid = jsonStrGet(elm, "AID");
@@ -175,8 +182,9 @@ int PrintAIDDescription(json_t *xroot, char *aid, bool verbose) {
}
out:
if (xroot == NULL)
if (xroot == NULL) {
AIDSearchFree(root);
}
return retval;
}
+1 -1
View File
@@ -39,7 +39,7 @@ const char *getAtrInfo(const char *atr_str) {
char *tmp_atr = calloc(slen, sizeof(uint8_t));
if (tmp_atr == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return NULL;
}
+1
View File
@@ -908,6 +908,7 @@ static int CmdAnalyseDemodBuffer(const char *Cmd) {
// add 1 for null terminator.
uint8_t *data = calloc(len + 1, sizeof(uint8_t));
if (data == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
CLIParserFree(ctx);
return PM3_EMALLOC;
}

Some files were not shown because too many files have changed in this diff Show More