diff --git a/client/cmdflashmem.c b/client/cmdflashmem.c index af8584ce7..2a9709ef0 100644 --- a/client/cmdflashmem.c +++ b/client/cmdflashmem.c @@ -260,9 +260,12 @@ int CmdFlashMemLoad(const char *Cmd) { break; } - data = realloc(data, datalen); - if (!data) { + uint8_t *newdata = realloc(data, datalen); + if (newdata == NULL) { + free(data); return 1; + } else { + data = newdata; } //Send to device diff --git a/client/cmdlfkeri.c b/client/cmdlfkeri.c index 3228e31f4..0fda6c683 100644 --- a/client/cmdlfkeri.c +++ b/client/cmdlfkeri.c @@ -41,8 +41,8 @@ int usage_lf_keri_sim(void) { // find KERI preamble in already demoded data int detectKeri(uint8_t *dest, size_t *size, bool *invert) { - uint8_t preamble[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; - uint8_t preamble_i[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}; + uint8_t preamble[] = {1,1,1,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; + uint8_t preamble_i[] = {0,0,0,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}; // sanity check. if (*size < sizeof(preamble) + 100) return -1; @@ -157,18 +157,16 @@ int CmdKeriClone(const char *Cmd) { 2 << T5555_MAXBLOCK_SHIFT; } - // MSB is ONE internalid |= 0x80000000; - + // 3 LSB is ONE uint64_t data = ((uint64_t)internalid << 3) + 7; + PrintAndLogEx(INFO, "Preparing to clone KERI to T55x7 with Internal Id: %" PRIx64, internalid ); // blocks[1] = data >> 32; blocks[2] = data & 0xFFFFFFFF; - - PrintAndLogEx(INFO, "Preparing to clone KERI to T55x7 with Internal Id: %u", internalid); print_blocks(blocks, 3); diff --git a/client/cmdlfparadox.c b/client/cmdlfparadox.c index 02ff02005..23d45bc27 100644 --- a/client/cmdlfparadox.c +++ b/client/cmdlfparadox.c @@ -147,8 +147,8 @@ int CmdParadoxRead(const char *Cmd) { int CmdParadoxSim(const char *Cmd) { - char cmdp = param_getchar(Cmd, 0); - if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_paradox_sim(); + char cmdp = tolower(param_getchar(Cmd, 0)); + if (strlen(Cmd) == 0 || cmdp == 'h') return usage_lf_paradox_sim(); uint32_t facilitycode = 0, cardnumber = 0, fc = 0, cn = 0; diff --git a/client/cmdlfpyramid.c b/client/cmdlfpyramid.c index bcf5ab672..a2f5942ad 100644 --- a/client/cmdlfpyramid.c +++ b/client/cmdlfpyramid.c @@ -55,7 +55,7 @@ int detectPyramid(uint8_t *dest, size_t *size, int *waveStartIdx) { if (getSignalProperties()->isnoise) return -2; // FSK demodulator RF/50 FSK 10,8 - *size = fskdemod(dest, *size, 50, 0, 10, 8, waveStartIdx); // pyramid fsk2 + *size = fskdemod(dest, *size, 50, 1, 10, 8, waveStartIdx); // pyramid fsk2 //did we get a good demod? if (*size < 128) return -3; @@ -235,11 +235,13 @@ int CmdPyramidDemod(const char *Cmd) { PrintAndLogEx(SUCCESS, "Pyramid ID Found - BitLength: %d -unknown BitLength- (%d), Raw: %08x%08x%08x%08x", fmtLen, cardnum, rawHi3, rawHi2, rawHi, rawLo); } } - if (checksum == checkCS) - PrintAndLogEx(SUCCESS, "Checksum %02x passed", checksum); - else - PrintAndLogEx(FAILED, "Checksum %02x failed - should have been %02x", checksum, checkCS); + PrintAndLogEx(DEBUG, "DEBUG: Pyramid: checksum : 0x%02X - %02X - %s" + , checksum + , checkCS + , (checksum == checkCS) ? _GREEN_("Passed") : _RED_("Failed") + ); + PrintAndLogEx(DEBUG, "DEBUG: Pyramid: idx: %d, Len: %d, Printing Demod Buffer:", idx, 128); if (g_debugMode) printDemodBuff(); diff --git a/client/cmdlfti.c b/client/cmdlfti.c index 5d3c2e399..dcf63125c 100644 --- a/client/cmdlfti.c +++ b/client/cmdlfti.c @@ -254,7 +254,7 @@ int CmdTIDemod(const char *Cmd) { //crc = crc16_ccitt(message, sizeof(message); - char *crcStr = (crc == (shift2 & 0xFFFF)) ? "Passed" : "Failed"; + char *crcStr = (crc == (shift2 & 0xFFFF)) ? _GREEN_("Passed") : _RED_("Failed"); PrintAndLogEx(INFO, "Tag data = %08X%08X [Crc %04X %s]", shift1, shift0, crc, crcStr); diff --git a/client/fpga_compress.c b/client/fpga_compress.c index cdd899782..c7cd021f8 100644 --- a/client/fpga_compress.c +++ b/client/fpga_compress.c @@ -167,7 +167,6 @@ int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, bool hardn fclose(infile[j]); } fclose(outfile); - free(infile); free(fpga_config); return (EXIT_FAILURE); } @@ -182,7 +181,6 @@ int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, bool hardn fclose(infile[j]); } fclose(outfile); - free(infile); free(fpga_config); return (EXIT_SUCCESS); @@ -429,9 +427,11 @@ int main(int argc, char **argv) { return (EXIT_FAILURE); } - return zlib_decompress(infiles[0], outfile); + int ret = zlib_decompress(infiles[0], outfile); + free(infiles); + return (ret); - } else { // Compress or gemerate version info + } else { // Compress or generate version info bool hardnested_mode = false; bool generate_version_file = false; @@ -476,7 +476,10 @@ int main(int argc, char **argv) { return (EXIT_FAILURE); } } else { - return zlib_compress(infiles, num_input_files, outfile, hardnested_mode); + int ret = zlib_compress(infiles, num_input_files, outfile, hardnested_mode); + free(infile_names); + free(infiles); + return (ret); } } }