unify test - step 2

This commit is contained in:
iceman1001
2025-03-25 10:17:42 +01:00
parent 875b3c44b4
commit ad292e8810
70 changed files with 272 additions and 195 deletions
+11 -1
View File
@@ -802,8 +802,10 @@ static int emrtd_dump_ef_dg2(uint8_t *file_contents, size_t file_length, const c
}
char *filepath = calloc(strlen(path) + 100, sizeof(char));
if (filepath == NULL)
if (filepath == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
strcpy(filepath, path);
strncat(filepath, PATHSEP, 2);
@@ -827,6 +829,7 @@ static int emrtd_dump_ef_dg5(uint8_t *file_contents, size_t file_length, const c
if (datalen < EMRTD_MAX_FILE_SIZE) {
char *filepath = calloc(strlen(path) + 100, sizeof(char));
if (filepath == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
strcpy(filepath, path);
@@ -855,6 +858,7 @@ static int emrtd_dump_ef_dg7(uint8_t *file_contents, size_t file_length, const c
if (datalen < EMRTD_MAX_FILE_SIZE) {
char *filepath = calloc(strlen(path) + 100, sizeof(char));
if (filepath == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
strcpy(filepath, path);
@@ -882,6 +886,7 @@ static int emrtd_dump_ef_sod(uint8_t *file_contents, size_t file_length, const c
char *filepath = calloc(strlen(path) + 100, sizeof(char));
if (filepath == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -904,6 +909,7 @@ static bool emrtd_dump_file(uint8_t *ks_enc, uint8_t *ks_mac, uint8_t *ssc, uint
char *filepath = calloc(strlen(path) + 100, sizeof(char));
if (filepath == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return false;
}
@@ -1124,6 +1130,7 @@ int dumpHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_availab
char *filepath = calloc(strlen(path) + 100, sizeof(char));
if (filepath == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -2095,6 +2102,7 @@ int infoHF_EMRTD_offline(const char *path) {
size_t datalen = 0;
char *filepath = calloc(strlen(path) + 100, sizeof(char));
if (filepath == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
strcpy(filepath, path);
@@ -2168,11 +2176,13 @@ int infoHF_EMRTD_offline(const char *path) {
// Read files in the file list
for (int i = 0; i < filelistlen; i++) {
emrtd_dg_t *dg = emrtd_tag_to_dg(filelist[i]);
if (dg == NULL) {
PrintAndLogEx(INFO, "File tag not found, skipping... %02X", filelist[i]);
continue;
}
if (!dg->pace && !dg->eac) {
strcpy(filepath, path);
strncat(filepath, PATHSEP, 2);
+3 -1
View File
@@ -81,11 +81,13 @@ static int CmdHFEPACollectPACENonces(const char *Cmd) {
} else {
size_t nonce_length = resp.oldarg[1];
size_t nonce_length_bytes = 2 * nonce_length + 1;
char *nonce = (char *) calloc(2 * nonce_length + 1, sizeof(uint8_t));
if (nonce == NULL) {
PrintAndLogEx(FAILED, "Memory allocation failed for nonce");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
for (int j = 0; j < nonce_length; j++) {
int nonce_offset = 2 * j;
snprintf(nonce + nonce_offset, (nonce_length_bytes * sizeof(uint8_t)) - nonce_offset, "%02X", resp.data.asBytes[j]);
+2 -2
View File
@@ -2089,11 +2089,11 @@ static int CmdHFFelicaDumpLite(const char *Cmd) {
uint8_t *trace = calloc(tracelen, sizeof(uint8_t));
if (trace == NULL) {
PrintAndLogEx(WARNING, "failed to allocate memory ");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
if (!GetFromDevice(BIG_BUF, trace, tracelen, 0, NULL, 0, NULL, 2500, false)) {
if (GetFromDevice(BIG_BUF, trace, tracelen, 0, NULL, 0, NULL, 2500, false) == false) {
PrintAndLogEx(WARNING, "command execution time out");
free(trace);
return PM3_ETIMEOUT;
+3 -2
View File
@@ -72,7 +72,7 @@ static char *GenerateFilename(iso14a_card_select_t *card, const char *prefix, co
}
char *fptr = calloc(sizeof(char) * (strlen(prefix) + strlen(suffix)) + sizeof(card->uid) * 2 + 1, sizeof(uint8_t));
if (fptr == NULL) {
PrintAndLogEx(FAILED, "Memory allocation failed");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return NULL;
}
strcpy(fptr, prefix);
@@ -344,8 +344,9 @@ static int CmdHFFudanDump(const char *Cmd) {
// create filename if none was given
if (strlen(dataFilename) < 1) {
char *fptr = GenerateFilename(&card, "hf-fudan-", "-dump");
if (fptr == NULL)
if (fptr == NULL) {
return PM3_ESOFT;
}
strcpy(dataFilename, fptr);
free(fptr);
+1 -1
View File
@@ -60,7 +60,7 @@ int hfgal_diversify_key(uint8_t *site_key, uint8_t *uid, uint8_t uid_len,
int res = mfdes_kdf_input_gallagher(uid, uid_len, key_num, aid, key_output, &kdf_input_len);
PM3_RET_IF_ERR_WITH_MSG(res, "Failed generating Gallagher key diversification input");
uint8_t key[sizeof(DEFAULT_SITE_KEY)];
uint8_t key[sizeof(DEFAULT_SITE_KEY)] = {0};
if (site_key == NULL) {
PrintAndLogEx(INFO, "hfgal_diversify_key is using default site key");
memcpy(key, DEFAULT_SITE_KEY, sizeof(key));
+12 -9
View File
@@ -387,7 +387,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
// normal size
uint8_t *data = calloc(1, tot_bytes);
if (data == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -433,7 +433,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
uint8_t *p = realloc(data, tot_bytes);
if (p == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
free(data);
return PM3_EMALLOC;
}
@@ -935,7 +935,7 @@ static int CmdHFiClassSim(const char *Cmd) {
size_t datalen = NUM_CSNS * MAC_ITEM_SIZE;
uint8_t *dump = calloc(datalen, sizeof(uint8_t));
if (!dump) {
if (dump == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -986,7 +986,7 @@ static int CmdHFiClassSim(const char *Cmd) {
size_t datalen = NUM_CSNS * MAC_ITEM_SIZE;
uint8_t *dump = calloc(datalen, sizeof(uint8_t));
if (!dump) {
if (dump == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1102,7 +1102,7 @@ int read_iclass_csn(bool loop, bool verbose, bool shallow_mod) {
free(card);
res = PM3_SUCCESS;
} else {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
res = PM3_EMALLOC;
}
}
@@ -1263,7 +1263,7 @@ static int CmdHFiClassESave(const char *Cmd) {
uint8_t *dump = calloc(bytes, sizeof(uint8_t));
if (dump == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1326,7 +1326,7 @@ static int CmdHFiClassEView(const char *Cmd) {
uint8_t *dump = calloc(bytes, sizeof(uint8_t));
if (dump == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
memset(dump, 0, bytes);
@@ -1418,6 +1418,7 @@ static int iclass_decode_credentials_new_pacs(uint8_t *d) {
char *binstr = (char *)calloc((PICOPASS_BLOCK_SIZE * 8) + 1, sizeof(uint8_t));
if (binstr == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -3914,6 +3915,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
keycount = 5000;
keyBlock = calloc(1, keycount * 8);
if (keyBlock == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -3959,7 +3961,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
// allocate memory for the pre calculated macs
iclass_premac_t *pre = calloc(keycount, sizeof(iclass_premac_t));
if (pre == NULL) {
PrintAndLogEx(WARNING, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -4021,7 +4023,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
uint32_t tmp_plen = sizeof(iclass_chk_t) + (4 * curr_chunk_cnt);
iclass_chk_t *packet = calloc(tmp_plen, sizeof(uint8_t));
if (packet == NULL) {
PrintAndLogEx(WARNING, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
break;
}
packet->use_credit_key = use_credit_key;
@@ -4674,6 +4676,7 @@ static int CmdHFiClassLookUp(const char *Cmd) {
keycount = 5000;
keyBlock = calloc(1, keycount * 8);
if (keyBlock == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
+1 -1
View File
@@ -520,7 +520,7 @@ static int CmdHfIctCredential(const char *Cmd) {
uint16_t sc_size = mfNumBlocksPerSector(ICT_MIFARE_SECTOR) * MFBLOCK_SIZE;
uint8_t *data = calloc(sc_size, sizeof(uint8_t));
if (data == NULL) {
PrintAndLogEx(ERR, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
+1 -1
View File
@@ -492,7 +492,7 @@ static int CmdHF14AJookiSim(const char *Cmd) {
// hf mfu sim...
uint8_t *data = calloc(144, sizeof(uint8_t));
if (data == NULL) {
PrintAndLogEx(ERR, "Memory allocation failed");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
+17 -17
View File
@@ -67,7 +67,7 @@ static int decode_and_print_memory(uint16_t card_size, const uint8_t *input_buff
// copy input buffer into newly allocated buffer, because the existing code mutates the data inside.
uint8_t *data = calloc(card_size, sizeof(uint8_t));
if (data == NULL) {
PrintAndLogEx(WARNING, "Cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
memcpy(data, input_buffer, card_size);
@@ -432,7 +432,7 @@ static int CmdLegicInfo(const char *Cmd) {
// allocate receiver buffer
uint8_t *data = calloc(card.cardsize, sizeof(uint8_t));
if (data == NULL) {
PrintAndLogEx(WARNING, "Cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -494,8 +494,8 @@ static int CmdLegicRdbl(const char *Cmd) {
// allocate receiver buffer
uint8_t *data = calloc(len, sizeof(uint8_t));
if (!data) {
PrintAndLogEx(WARNING, "Cannot allocate memory");
if (data == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -643,7 +643,7 @@ static int CmdLegicWrbl(const char *Cmd) {
legic_packet_t *payload = calloc(1, sizeof(legic_packet_t) + dlen);
if (payload == NULL) {
PrintAndLogEx(WARNING, "Cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
payload->offset = (offset & 0xFFFF);
@@ -724,7 +724,7 @@ int legic_read_mem(uint32_t offset, uint32_t len, uint32_t iv, uint8_t *out, uin
legic_packet_t *payload = calloc(1, sizeof(legic_packet_t));
if (payload == NULL) {
PrintAndLogEx(WARNING, "Cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
payload->offset = (offset & 0xFFFF);
@@ -826,7 +826,7 @@ void legic_seteml(uint8_t *src, uint32_t offset, uint32_t numofbytes) {
legic_packet_t *payload = calloc(1, sizeof(legic_packet_t) + len);
if (payload == NULL) {
PrintAndLogEx(WARNING, "Cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return;
}
payload->offset = i;
@@ -902,7 +902,7 @@ static int CmdLegicDump(const char *Cmd) {
legic_packet_t *payload = calloc(1, sizeof(legic_packet_t));
if (payload == NULL) {
PrintAndLogEx(WARNING, "Cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
payload->offset = 0;
@@ -932,8 +932,8 @@ static int CmdLegicDump(const char *Cmd) {
uint16_t readlen = resp.data.asDwords[0];
uint8_t *data = calloc(readlen, sizeof(uint8_t));
if (!data) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
if (data == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1044,7 +1044,7 @@ static int CmdLegicRestore(const char *Cmd) {
legic_packet_t *payload = calloc(1, sizeof(legic_packet_t) + len);
if (payload == NULL) {
PrintAndLogEx(WARNING, "Cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
free(dump);
return PM3_EMALLOC;
}
@@ -1184,7 +1184,7 @@ static int CmdLegicESave(const char *Cmd) {
// set up buffer
uint8_t *data = calloc(numofbytes, sizeof(uint8_t));
if (data == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1253,7 +1253,7 @@ static int CmdLegicEView(const char *Cmd) {
uint8_t *dump = calloc(bytes, sizeof(uint8_t));
if (dump == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1317,7 +1317,7 @@ static int CmdLegicEInfo(const char *Cmd) {
uint8_t *dump = calloc(card_size, sizeof(uint8_t));
if (dump == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1357,8 +1357,8 @@ static int CmdLegicWipe(const char *Cmd) {
// set up buffer
uint8_t *data = calloc(card.cardsize, sizeof(uint8_t));
if (!data) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
if (data == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1382,7 +1382,7 @@ static int CmdLegicWipe(const char *Cmd) {
legic_packet_t *payload = calloc(1, sizeof(legic_packet_t) + len);
if (payload == NULL) {
PrintAndLogEx(WARNING, "Cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
free(data);
return PM3_EMALLOC;
}
+2 -2
View File
@@ -755,8 +755,8 @@ static int CmdHfLTODump(const char *Cmd) {
uint32_t dump_len = CM_MEM_MAX_SIZE;
uint8_t *dump = calloc(dump_len, sizeof(uint8_t));
if (!dump) {
PrintAndLogEx(ERR, "error, cannot allocate memory");
if (dump == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
+19 -18
View File
@@ -753,8 +753,8 @@ static int mf_load_keys(uint8_t **pkeyBlock, uint32_t *pkeycnt, uint8_t *userkey
if (userkeylen >= MIFARE_KEY_SIZE) {
int numKeys = userkeylen / MIFARE_KEY_SIZE;
p = realloc(*pkeyBlock, numKeys * MIFARE_KEY_SIZE);
if (!p) {
PrintAndLogEx(FAILED, "cannot allocate memory for Keys");
if (p == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
free(*pkeyBlock);
return PM3_EMALLOC;
}
@@ -772,8 +772,8 @@ static int mf_load_keys(uint8_t **pkeyBlock, uint32_t *pkeycnt, uint8_t *userkey
if (load_default) {
// Handle default keys
p = realloc(*pkeyBlock, (*pkeycnt + ARRAYLEN(g_mifare_default_keys)) * MIFARE_KEY_SIZE);
if (!p) {
PrintAndLogEx(FAILED, "cannot allocate memory for Keys");
if (p == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
free(*pkeyBlock);
return PM3_EMALLOC;
}
@@ -799,8 +799,8 @@ static int mf_load_keys(uint8_t **pkeyBlock, uint32_t *pkeycnt, uint8_t *userkey
return PM3_EFILE;
} else {
p = realloc(*pkeyBlock, (*pkeycnt + loaded_numKeys) * MIFARE_KEY_SIZE);
if (!p) {
PrintAndLogEx(FAILED, "cannot allocate memory for Keys");
if (p == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
free(keyBlock_tmp);
free(*pkeyBlock);
return PM3_EMALLOC;
@@ -1155,7 +1155,7 @@ static int CmdHF14AMfRdSc(const char *Cmd) {
uint8_t *data = calloc(sc_size, sizeof(uint8_t));
if (data == NULL) {
PrintAndLogEx(ERR, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1315,7 +1315,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
iso14a_card_select_t card ;
uint8_t *mem = calloc(MIFARE_4K_MAX_BYTES, sizeof(uint8_t));
if (mem == NULL) {
PrintAndLogEx(ERR, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
int res = mfc_read_tag(&card, mem, numSectors, keyFilename);
@@ -3290,7 +3290,7 @@ all_found:
bytes = block_cnt * MFBLOCK_SIZE;
uint8_t *dump = calloc(bytes, sizeof(uint8_t));
if (dump == NULL) {
PrintAndLogEx(ERR, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
free(e_sector);
free(fptr);
return PM3_EMALLOC;
@@ -4913,7 +4913,7 @@ static int CmdHF14AMfESave(const char *Cmd) {
// reserv memory
uint8_t *dump = calloc(bytes, sizeof(uint8_t));
if (dump == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
memset(dump, 0, bytes);
@@ -4991,7 +4991,7 @@ static int CmdHF14AMfEView(const char *Cmd) {
uint8_t *dump = calloc(bytes, sizeof(uint8_t));
if (dump == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -5787,7 +5787,7 @@ static int CmdHF14AMfCSave(const char *Cmd) {
uint16_t bytes = block_cnt * MFBLOCK_SIZE;
uint8_t *dump = calloc(bytes, sizeof(uint8_t));
if (dump == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -5937,7 +5937,7 @@ static int CmdHF14AMfCView(const char *Cmd) {
uint16_t bytes = block_cnt * MFBLOCK_SIZE;
uint8_t *dump = calloc(bytes, sizeof(uint8_t));
if (dump == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -7949,6 +7949,7 @@ static int CmdHF14AMfView(const char *Cmd) {
UDATA d;
d.bytes = calloc(bytes_read, sizeof(uint8_t));
if (d.bytes == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
uint16_t dlen = 0;
@@ -8418,7 +8419,7 @@ static int CmdHF14AGen4Load(const char *cmd) {
if (fill_from_emulator) {
data = calloc(block_cnt * MFBLOCK_SIZE, sizeof(uint8_t));
if (data == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -8620,7 +8621,7 @@ static int CmdHF14AGen4View(const char *Cmd) {
uint16_t bytes = block_cnt * MFBLOCK_SIZE;
uint8_t *dump = calloc(bytes, sizeof(uint8_t));
if (dump == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -8763,7 +8764,7 @@ static int CmdHF14AGen4Save(const char *Cmd) {
uint16_t bytes = block_cnt * MFBLOCK_SIZE;
uint8_t *dump = calloc(bytes, sizeof(uint8_t));
if (dump == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -10161,10 +10162,10 @@ static int CmdHF14AMfISEN(const char *Cmd) {
uint8_t *dump = calloc(bytes, sizeof(uint8_t));
if (dump == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EFAILED;
}
if (!GetFromDevice(BIG_BUF_EML, dump, bytes, 0, NULL, 0, NULL, 2500, false)) {
if (GetFromDevice(BIG_BUF_EML, dump, bytes, 0, NULL, 0, NULL, 2500, false) == false) {
PrintAndLogEx(WARNING, "Fail, transfer from device time-out");
free(dump);
return PM3_ETIMEOUT;
+6 -4
View File
@@ -459,11 +459,11 @@ static int mfdes_get_info(mfdes_info_res_t *info) {
int desfire_print_signature(uint8_t *uid, uint8_t uidlen, uint8_t *signature, size_t signature_len) {
if (uid == NULL) {
PrintAndLogEx(DEBUG, "UID=NULL");
PrintAndLogEx(DEBUG, "UID is NULL");
return PM3_EINVARG;
}
if (signature == NULL) {
PrintAndLogEx(DEBUG, "SIGNATURE=NULL");
PrintAndLogEx(DEBUG, "SIGNATURE is NULL");
return PM3_EINVARG;
}
@@ -472,7 +472,9 @@ int desfire_print_signature(uint8_t *uid, uint8_t uidlen, uint8_t *signature, si
}
static void swap24(uint8_t *data) {
if (data == NULL) return;
if (data == NULL) {
return;
}
uint8_t tmp = data[0];
data[0] = data[2];
data[2] = tmp;
@@ -4850,7 +4852,7 @@ static int DesfileReadFileAndPrint(DesfireContext_t *dctx,
uint8_t *resp = calloc(DESFIRE_BUFFER_SIZE, 1);
if (resp == NULL) {
PrintAndLogEx(ERR, "Desfire calloc " _RED_("error"));
PrintAndLogEx(WARNING, "Failed to allocate memory");
DropField();
return PM3_EMALLOC;
}
+10
View File
@@ -708,12 +708,22 @@ static int add_nonce(uint32_t nonce_enc, uint8_t par_enc) {
} else { // add new entry at end of existing list.
p2 = p2->next = calloc(1, sizeof(noncelistentry_t));
}
if (p2 == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
}
} else if ((p1->nonce_enc & 0x00ff0000) != (nonce_enc & 0x00ff0000)) { // found distinct 2nd byte. Need to insert.
if (p2 == NULL) { // need to insert at start of list
p2 = nonces[first_byte].first = calloc(1, sizeof(noncelistentry_t));
} else {
p2 = p2->next = calloc(1, sizeof(noncelistentry_t));
}
if (p2 == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
}
} else { // we have seen this 2nd byte before. Nothing to add or insert.
return (0);
}
+2 -2
View File
@@ -1676,7 +1676,7 @@ static int CmdHFMFPChk(const char *Cmd) {
char *fptr = calloc(sizeof(char) * (strlen("hf-mfp-") + strlen("-key")) + card.uidlen * 2 + 1, sizeof(uint8_t));
if (fptr == NULL) {
PrintAndLogEx(ERR, "Memory allocation failed");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
strcpy(fptr, "hf-mfp-");
@@ -1742,7 +1742,7 @@ static int CmdHFMFPDump(const char *Cmd) {
// read card
uint8_t *mem = calloc(MIFARE_4K_MAXBLOCK * MFBLOCK_SIZE, sizeof(uint8_t));
if (mem == NULL) {
PrintAndLogEx(ERR, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
+5 -5
View File
@@ -307,7 +307,7 @@ static const char *getUlev1CardSizeStr(uint8_t fsize) {
int ul_read_uid(uint8_t *uid) {
if (uid == NULL) {
PrintAndLogEx(WARNING, "NUll parameter UID");
PrintAndLogEx(WARNING, "UID is NULL");
return PM3_ESOFT;
}
// read uid from tag
@@ -1573,7 +1573,7 @@ static char *mfu_generate_filename(const char *prefix, const char *suffix) {
char *fptr = calloc(sizeof(char) * (strlen(prefix) + strlen(suffix)) + sizeof(card.uid) * 2 + 1, sizeof(uint8_t));
if (fptr == NULL) {
PrintAndLogEx(FAILED, "Memory allocation failed");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return NULL;
}
strcpy(fptr, prefix);
@@ -1596,7 +1596,7 @@ static int mfu_dump_tag(uint16_t pages, void **pdata, uint16_t *len) {
*pdata = calloc(maxbytes, sizeof(uint8_t));
if (*pdata == NULL) {
PrintAndLogEx(FAILED, "error, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
res = PM3_EMALLOC;
goto out;
}
@@ -1867,7 +1867,7 @@ static int mfu_fingerprint(uint64_t tagtype, bool hasAuthKey, const uint8_t *aut
maxbytes = ((maxbytes / MFU_BLOCK_SIZE) + 1) * MFU_BLOCK_SIZE;
data = calloc(maxbytes, sizeof(uint8_t));
if (data == NULL) {
PrintAndLogEx(ERR, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
res = PM3_EMALLOC;
goto out;
}
@@ -5304,7 +5304,7 @@ static int GetMfuDumpFromEMul(mfu_dump_t **buf) {
mfu_dump_t *dump = calloc(1, sizeof(mfu_dump_t));
if (dump == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
+9 -5
View File
@@ -155,13 +155,17 @@ static void ntag424_print_version_information(ntag424_version_information_t *ver
if (is_hw) {
const char *capacitance = "unknown";
switch (version->sub_type & 0xf) {
case 2: capacitance = "50pF";
case 8: capacitance = "50pF + Tag Tamper";
case 2:
capacitance = "50pF";
case 8:
capacitance = "50pF + Tag Tamper";
}
const char *modulation = "unknown";
switch ((version->sub_type >> 4) & 0xf) {
case 0: modulation = "strong";
case 8: modulation = "standard";
case 0:
modulation = "strong";
case 8:
modulation = "standard";
}
PrintAndLogEx(INFO, " sub type: " _GREEN_("%02X (capacitance: %s, modulation: %s)"), version->sub_type, capacitance, modulation);
} else {
@@ -305,7 +309,7 @@ static void ntag424_calc_mac(const ntag424_session_keys_t *session_keys, uint8_t
uint8_t *mac_input = (uint8_t *)calloc(mac_input_len, sizeof(uint8_t));
if (mac_input == NULL) {
PrintAndLogEx(ERR, "Memory allocation failed");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return;
}
memcpy(mac_input, mac_input_header, sizeof(mac_input_header));
+3 -2
View File
@@ -362,6 +362,7 @@ static int topaz_set_cc_dynamic(const uint8_t *data) {
topaz_tag.size = memsize;
topaz_tag.dynamic_memory = calloc(memsize - TOPAZ_STATIC_MEMORY, sizeof(uint8_t));
if (topaz_tag.dynamic_memory == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
return PM3_SUCCESS;
@@ -543,7 +544,7 @@ static void topaz_print_control_TLVs(uint8_t *memory) {
if (old == NULL) {
new = topaz_tag.dynamic_lock_areas = (dynamic_lock_area_t *) calloc(sizeof(dynamic_lock_area_t), sizeof(uint8_t));
if (new == NULL) {
PrintAndLogEx(ERR, "Memory allocation failed");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return;
}
} else {
@@ -552,7 +553,7 @@ static void topaz_print_control_TLVs(uint8_t *memory) {
}
new = old->next = (dynamic_lock_area_t *) calloc(sizeof(dynamic_lock_area_t), sizeof(uint8_t));
if (new == NULL) {
PrintAndLogEx(ERR, "Memory allocation failed");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return;
}
}
+1 -1
View File
@@ -115,7 +115,7 @@ static int CreateGetVASDataCommand(const uint8_t *pidHash, const char *url, size
size_t reqTlvLen = 19 + (pidHash != NULL ? 35 : 0) + (url != NULL ? 3 + urlLen : 0);
uint8_t *reqTlv = calloc(reqTlvLen, sizeof(uint8_t));
if (reqTlv == NULL) {
PrintAndLogEx(FAILED, "Memory allocation failed");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
+1 -1
View File
@@ -635,7 +635,7 @@ static int read_xerox_block(iso14b_card_select_t *card, uint8_t blockno, uint8_t
uint8_t approx_len = (2 + card->uidlen + 1);
iso14b_raw_cmd_t *packet = (iso14b_raw_cmd_t *)calloc(1, sizeof(iso14b_raw_cmd_t) + approx_len);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
+2 -2
View File
@@ -687,8 +687,8 @@ static int CmdReadmem(const char *Cmd) {
CLIParserFree(ctx);
uint8_t *buffer = calloc(len, sizeof(uint8_t));
if (!buffer) {
PrintAndLogEx(ERR, "error, cannot allocate memory ");
if (buffer == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}

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