unify text - step 1

This commit is contained in:
iceman1001 committed 2025-03-25 10:12:16 +01:00
1 parent 090f31d0a7
commit 875b3c44b4
40 files changed
+167 -128

No files matched your search

+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;
}
+7 -4
View File
@@ -57,7 +57,7 @@ static int split(char *str, char *arr[MAX_ARGS]) {
int len = endIndex - beginIndex;
char *tmp = calloc(len + 1, sizeof(char));
if (tmp == NULL) {
PrintAndLogEx(WARNING, "Memory allocation failed");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return wordCnt;
}
memcpy(tmp, &str[beginIndex], len);
@@ -101,7 +101,7 @@ int GetModels(char *Models[], int *count, uint8_t *width) {
char *tmp = calloc(size + 1, sizeof(char));
if (tmp == NULL) {
PrintAndLogEx(WARNING, "out of memory?");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return 0;
}
@@ -202,7 +202,7 @@ int GetModels(char *Models[], int *count, uint8_t *width) {
//PrintAndLogEx(NORMAL, "Size: %d, %s, count: %d",size,pset.name, Cnt);
char *tmp = calloc(size + 1, sizeof(char));
if (tmp == NULL) {
PrintAndLogEx(WARNING, "out of memory?");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return 0;
}
@@ -433,9 +433,10 @@ static int CmdrevengTestC(const char *Cmd) {
static char *SwapEndianStr(const char *inStr, const size_t len, const uint8_t blockSize) {
char *tmp = calloc(len + 1, sizeof(char));
if (tmp == NULL) {
PrintAndLogEx(WARNING, "Memory allocation failed");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return NULL;
}
for (uint8_t block = 0; block < (uint8_t)(len / blockSize); block++) {
for (size_t i = 0; i < blockSize; i += 2) {
tmp[i + (blockSize * block)] = inStr[(blockSize - 1 - i - 1) + (blockSize * block)];
@@ -501,6 +502,7 @@ static int CmdrevengSearch(const char *Cmd) {
memset(result, 0, sizeof(result));
char *inCRC = calloc(crcChars + 1, sizeof(char));
if (inCRC == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return 0;
}
@@ -508,6 +510,7 @@ static int CmdrevengSearch(const char *Cmd) {
char *outHex = calloc(dataLen - crcChars + 1, sizeof(char));
if (outHex == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
free(inCRC);
return 0;
}
+32 -25
View File
@@ -94,13 +94,17 @@ static char *commaprint(size_t n) {
// set the g_DemodBuffer with given array ofq binary (one bit per byte)
void setDemodBuff(const uint8_t *buff, size_t size, size_t start_idx) {
if (buff == NULL) return;
if (buff == NULL) {
return;
}
if (size > MAX_DEMOD_BUF_LEN - start_idx)
if (size > MAX_DEMOD_BUF_LEN - start_idx) {
size = MAX_DEMOD_BUF_LEN - start_idx;
}
for (size_t i = 0; i < size; i++)
for (size_t i = 0; i < size; i++) {
g_DemodBuffer[i] = buff[start_idx++];
}
g_DemodBufferLen = size;
}
@@ -254,7 +258,7 @@ int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_h
uint8_t *buf = calloc(len, sizeof(uint8_t));
if (buf == NULL) {
PrintAndLogEx(WARNING, "fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
memcpy(buf, g_DemodBuffer, len);
@@ -420,7 +424,7 @@ int ASKDemod_ext(int clk, int invert, int maxErr, size_t maxlen, bool amplify, b
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(INFO, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -595,7 +599,7 @@ static int Cmdmandecoderaw(const char *Cmd) {
uint8_t *bits = calloc(MAX_DEMOD_BUF_LEN, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -692,7 +696,7 @@ static int CmdBiphaseDecodeRaw(const char *Cmd) {
uint8_t *bits = calloc(MAX_DEMOD_BUF_LEN, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -733,7 +737,7 @@ int ASKbiphaseDemod(int offset, int clk, int invert, int maxErr, bool verbose) {
uint8_t *bs = calloc(MAX_DEMOD_BUF_LEN, sizeof(uint8_t));
if (bs == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1074,7 +1078,7 @@ static int CmdUndecimate(const char *Cmd) {
//We have memory, don't we?
int *swap = calloc(MAX_GRAPH_TRACE_LEN, sizeof(int));
if (swap == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
uint32_t g_index = 0, s_index = 0;
@@ -1271,7 +1275,7 @@ int FSKrawDemod(uint8_t rfLen, uint8_t invert, uint8_t fchigh, uint8_t fclow, bo
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1374,7 +1378,7 @@ int PSKDemod(int clk, int invert, int maxErr, bool verbose) {
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
size_t bitlen = getFromGraphBuffer(bits);
@@ -1424,7 +1428,7 @@ int NRZrawDemod(int clk, int invert, int maxErr, bool verbose) {
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1807,7 +1811,7 @@ int CmdHpf(const char *Cmd) {
uint8_t *bits = calloc(g_GraphTraceLen, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
size_t size = getFromGraphBuffer(bits);
@@ -1915,7 +1919,7 @@ int getSamplesFromBufEx(uint8_t *data, size_t sample_num, uint8_t bits_per_sampl
uint8_t *bits = calloc(g_GraphTraceLen, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
size_t size = getFromGraphBuffer(bits);
@@ -1991,7 +1995,7 @@ static int CmdLoad(const char *Cmd) {
f = fopen(path, "r");
if (f == NULL) {
PrintAndLogEx(WARNING, "couldn't open '%s'", path);
PrintAndLogEx(WARNING, "couldn't open `" _YELLOW_("%s") "`", path);
free(path);
return PM3_EFILE;
}
@@ -2005,8 +2009,9 @@ static int CmdLoad(const char *Cmd) {
g_GraphBuffer[g_GraphTraceLen] = val[0] - 127;
g_GraphTraceLen++;
if (g_GraphTraceLen >= MAX_GRAPH_TRACE_LEN)
if (g_GraphTraceLen >= MAX_GRAPH_TRACE_LEN) {
break;
}
}
} else {
char line[80];
@@ -2025,7 +2030,7 @@ static int CmdLoad(const char *Cmd) {
if (nofix == false) {
uint8_t *bits = calloc(g_GraphTraceLen, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
size_t size = getFromGraphBuffer(bits);
@@ -2172,7 +2177,7 @@ int CmdNorm(const char *Cmd) {
uint8_t *bits = calloc(g_GraphTraceLen, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
size_t size = getFromGraphBuffer(bits);
@@ -2323,7 +2328,7 @@ static int CmdDirectionalThreshold(const char *Cmd) {
// set signal properties low/high/mean/amplitude and isnoice detection
uint8_t *bits = calloc(g_GraphTraceLen, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
size_t size = getFromGraphBuffer(bits);
@@ -2371,7 +2376,7 @@ static int CmdZerocrossings(const char *Cmd) {
uint8_t *bits = calloc(g_GraphTraceLen, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
size_t size = getFromGraphBuffer(bits);
@@ -2383,8 +2388,9 @@ static int CmdZerocrossings(const char *Cmd) {
}
static bool data_verify_hex(uint8_t *d, size_t n) {
if (d == NULL)
if (d == NULL) {
return false;
}
for (size_t i = 0; i < n; i++) {
if (isxdigit(d[i]) == false) {
@@ -2655,9 +2661,10 @@ static int CmdDataIIR(const char *Cmd) {
uint8_t *bits = calloc(g_GraphTraceLen, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
size_t size = getFromGraphBuffer(bits);
// set signal properties low/high/mean/amplitude and is_noise detection
computeSignalProperties(bits, size);
@@ -2974,7 +2981,7 @@ static int CmdDiff(const char *Cmd) {
uint8_t *d = calloc(MIFARE_4K_MAX_BYTES, sizeof(uint8_t));
if (d == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -3418,7 +3425,7 @@ static int CmdCenterThreshold(const char *Cmd) {
// set signal properties low/high/mean/amplitude and isnoice detection
uint8_t *bits = calloc(g_GraphTraceLen, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
size_t size = getFromGraphBuffer(bits);
@@ -3468,7 +3475,7 @@ static int CmdEnvelope(const char *Cmd) {
uint8_t *bits = calloc(g_GraphTraceLen, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
size_t size = getFromGraphBuffer(bits);
+6 -5
View File
@@ -311,6 +311,7 @@ static int CmdFlashMemLoad(const char *Cmd) {
// ICEMAN: not needed when we transite to loadxxxx_safe methods
uint8_t *newdata = realloc(data, datalen);
if (newdata == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
free(data);
return PM3_EMALLOC;
} else {
@@ -413,13 +414,13 @@ static int CmdFlashMemDump(const char *Cmd) {
CLIParserFree(ctx);
uint8_t *dump = calloc(len, sizeof(uint8_t));
if (!dump) {
PrintAndLogEx(ERR, "error, cannot allocate memory ");
if (dump == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
PrintAndLogEx(INFO, "downloading "_YELLOW_("%u")" bytes from flash memory", len);
if (!GetFromDevice(FLASH_MEM, dump, len, offset, NULL, 0, NULL, -1, true)) {
if (GetFromDevice(FLASH_MEM, dump, len, offset, NULL, 0, NULL, -1, true) == false) {
PrintAndLogEx(FAILED, "ERROR; downloading from flash memory");
free(dump);
return PM3_EFLASH;
@@ -566,7 +567,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
mbedtls_rsa_context *rsa = (mbedtls_rsa_context *)pkctx.pk_ctx;
if (rsa == NULL) {
PrintAndLogEx(FAILED, "failed to allocate rsa context memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
got_private = true;
@@ -620,7 +621,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
rsa = (mbedtls_rsa_context *)calloc(1, sizeof(mbedtls_rsa_context));
if (rsa == NULL) {
PrintAndLogEx(FAILED, "failed to allocate rsa context memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
mbedtls_rsa_init(rsa, MBEDTLS_RSA_PKCS_V15, 0);
+3 -3
View File
@@ -47,7 +47,7 @@ int flashmem_spiffs_load(const char *destfn, const uint8_t *data, size_t datalen
flashmem_write_t *payload = calloc(1, sizeof(flashmem_write_t) + bytes_in_packet);
if (payload == NULL) {
PrintAndLogEx(ERR, "error, cannot allocate memory ");
PrintAndLogEx(WARNING, "Failed to allocate memory");
ret_val = PM3_EMALLOC;
goto out;
}
@@ -113,7 +113,7 @@ int flashmem_spiffs_download(char *fn, uint8_t fnlen, void **pdest, size_t *dest
*pdest = calloc(len, sizeof(uint8_t));
if (*pdest == false) {
PrintAndLogEx(ERR, "error, cannot allocate memory ");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -413,7 +413,7 @@ static int CmdFlashMemSpiFFSDump(const char *Cmd) {
uint32_t len = resp.data.asDwords[0];
uint8_t *dump = calloc(len, sizeof(uint8_t));
if (dump == NULL) {
PrintAndLogEx(ERR, "error, cannot allocate memory ");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
+4 -2
View File
@@ -279,8 +279,9 @@ static int CmdHF14AList(const char *Cmd) {
int hf14a_getconfig(hf14a_config *config) {
if (!g_session.pm3_present) return PM3_ENOTTY;
if (config == NULL)
if (config == NULL) {
return PM3_EINVARG;
}
clearCommandBuffer();
@@ -3254,9 +3255,10 @@ int CmdHF14ANdefRead(const char *Cmd) {
uint16_t ndef_size = (response[0] << 8) + response[1];
uint16_t offset = 2;
uint8_t *ndef_file = calloc(ndef_size, sizeof(uint8_t));
if (ndef_file == NULL) {
PrintAndLogEx(ERR, "Out of memory error in CmdHF14ANdef(). Aborting...\n");
PrintAndLogEx(WARNING, "Failed to allocate memory");
DropField();
return PM3_EMALLOC;
}
+8 -8
View File
@@ -392,13 +392,13 @@ uint8_t *get_uid_from_filename(const char *filename) {
memset(uid, 0, 8);
if (strlen(filename) < 23) {
PrintAndLogEx(ERR, "can't get uid from filename '%s'. Expected format is hf-14b-<uid>...", filename);
PrintAndLogEx(ERR, "can't get uid from filename `" _YELLOW_("%s") "` expected format is hf-14b-<uid>...", filename);
return uid;
}
char *found = strstr(filename, "hf-14b-");
if (found == NULL) {
PrintAndLogEx(ERR, "can't get uid from filename '%s'. Expected format is hf-14b-<uid>...", filename);
PrintAndLogEx(ERR, "can't get uid from filename `" _YELLOW_("%s") "` expected format is hf-14b-<uid>...", filename);
return uid;
}
@@ -1045,7 +1045,7 @@ static int CmdHF14BRaw(const char *Cmd) {
iso14b_raw_cmd_t *packet = (iso14b_raw_cmd_t *)calloc(1, sizeof(iso14b_raw_cmd_t) + datalen);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1250,7 +1250,7 @@ static int write_sr_block(uint8_t blockno, uint8_t datalen, uint8_t *data) {
uint8_t psize = sizeof(iso14b_raw_cmd_t) + datalen + 2;
iso14b_raw_cmd_t *packet = (iso14b_raw_cmd_t *)calloc(1, psize);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1433,7 +1433,7 @@ bool HF14B_picopass_reader(bool verbose, bool info) {
picopass_hdr_t *card = calloc(1, sizeof(picopass_hdr_t));
if (card == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return false;
}
memcpy(card, resp.data.asBytes, sizeof(picopass_hdr_t));
@@ -1465,7 +1465,7 @@ static bool HF14B_other_reader(bool verbose) {
iso14b_raw_cmd_t *packet = (iso14b_raw_cmd_t *)calloc(1, sizeof(iso14b_raw_cmd_t) + 4);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return false;
}
packet->flags = (ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_RAW | ISO14B_APPEND_CRC);
@@ -1795,7 +1795,7 @@ static int CmdHF14BDump(const char *Cmd) {
iso14b_raw_cmd_t *packet = (iso14b_raw_cmd_t *)calloc(1, sizeof(iso14b_raw_cmd_t) + 2);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
packet->flags = (ISO14B_CONNECT | ISO14B_SELECT_SR);
@@ -2235,7 +2235,7 @@ static int handle_14b_apdu(bool chainingin, uint8_t *datain, int datainlen,
iso14b_raw_cmd_t *packet = (iso14b_raw_cmd_t *)calloc(1, sizeof(iso14b_raw_cmd_t) + datainlen);
if (packet == NULL) {
PrintAndLogEx(FAILED, "APDU: failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
packet->flags = (ISO14B_APDU);
+17 -17
View File
@@ -426,7 +426,7 @@ static int getUID(bool verbose, bool loop, uint8_t *buf) {
uint8_t approxlen = 5;
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + approxlen);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -668,7 +668,7 @@ static int NxpTestEAS(const uint8_t *uid) {
uint8_t approxlen = 3 + HF15_UID_LENGTH + 2;
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + approxlen);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -723,7 +723,7 @@ static int NxpCheckSig(uint8_t *uid) {
uint8_t approxlen = 3 + HF15_UID_LENGTH + 2;
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + approxlen);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -777,7 +777,7 @@ static int NxpSysInfo(uint8_t *uid) {
uint8_t approxlen = 13;
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + approxlen);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -895,7 +895,7 @@ static int StCheckSig(uint8_t *uid) {
uint8_t approxlen = 2 + 8 + 1 + 2;
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + approxlen);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -998,7 +998,7 @@ static int CmdHF15Info(const char *Cmd) {
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + approxlen);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1195,7 +1195,7 @@ static int hf15EmlSetMem(const uint8_t *data, uint16_t count, size_t offset) {
size_t paylen = sizeof(struct p) + count;
struct p *payload = calloc(1, paylen);
if (payload == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1320,7 +1320,7 @@ static int CmdHF15ESave(const char *Cmd) {
// reserve 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;
}
@@ -1451,7 +1451,7 @@ static int CmdHF15EView(const char *Cmd) {
// reserve 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;
}
@@ -1726,7 +1726,7 @@ static int CmdHF15WriteDsfid(const char *Cmd) {
uint8_t approxlen = 2 + 8 + 1 + 2;
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + approxlen);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -1846,14 +1846,14 @@ static int CmdHF15Dump(const char *Cmd) {
uint8_t approxlen = 2 + 8 + 1 + 2;
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + approxlen);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
// struct of ISO15693 tag memory (new file format)
iso15_tag_t *tag = (iso15_tag_t *)calloc(1, sizeof(iso15_tag_t));
if (tag == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
free(packet);
return PM3_EMALLOC;
};
@@ -2098,7 +2098,7 @@ static int CmdHF15Raw(const char *Cmd) {
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + datalen);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -2222,7 +2222,7 @@ static int CmdHF15Readmulti(const char *Cmd) {
uint8_t approxlen = 2 + 8 + 2 + 2;
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + approxlen);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -2375,7 +2375,7 @@ static int CmdHF15Readblock(const char *Cmd) {
uint8_t approxlen = 2 + 8 + 1 + 2;
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + approxlen);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -2480,7 +2480,7 @@ static int hf_15_write_blk(const uint8_t *pm3flags, uint16_t flags, const uint8_
uint8_t approxlen = 21;
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + approxlen);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -2733,7 +2733,7 @@ static int CmdHF15Restore(const char *Cmd) {
uint16_t i = 0;
uint8_t *data = calloc(tag->bytesPerPage, sizeof(uint8_t));
if (data == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
free(tag);
return PM3_EMALLOC;
}
+5 -4
View File
@@ -103,8 +103,9 @@ static int CmdHFCryptoRFSniff(const char *Cmd) {
static bool get_14b_UID(iso14b_card_select_t *card) {
if (card == NULL)
if (card == NULL) {
return false;
}
int8_t retry = 3;
while (retry--) {
@@ -311,7 +312,7 @@ static int CmdHFCryptoRFDump(const char *Cmd) {
// select tag
iso14b_raw_cmd_t *packet = (iso14b_raw_cmd_t *)calloc(1, sizeof(iso14b_raw_cmd_t) + 2);
if (packet == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
packet->flags = (ISO14B_CONNECT | ISO14B_SELECT_SR);
@@ -445,7 +446,7 @@ static int CmdHFCryptoRFELoad(const char *Cmd) {
// set up buffer
uint8_t *data = calloc(datalen, sizeof(uint8_t));
if (data == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
@@ -505,7 +506,7 @@ static int CmdHFCryptoRFESave(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;
}