From 55b8b8df827841f0c9287877322f6b515f20fed7 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 23 Mar 2019 19:06:52 +0100 Subject: [PATCH 1/7] fix: 'lf pyramid demod' - inverted chg: checksum colors --- client/cmdlfpyramid.c | 12 +++++++----- client/cmdlfti.c | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/client/cmdlfpyramid.c b/client/cmdlfpyramid.c index bcf5ab672..bbdfc408b 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(SUCCESS, "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); From cfb11adeb8e1b662d62dc662b0fea484feb4869e Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 23 Mar 2019 19:08:22 +0100 Subject: [PATCH 2/7] simple check --- client/cmdlfparadox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; From 08dc8ab695db3e600858d41ffabde0e9eb7149d0 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 23 Mar 2019 19:09:37 +0100 Subject: [PATCH 3/7] debug --- client/cmdlfpyramid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/cmdlfpyramid.c b/client/cmdlfpyramid.c index bbdfc408b..a2f5942ad 100644 --- a/client/cmdlfpyramid.c +++ b/client/cmdlfpyramid.c @@ -236,7 +236,7 @@ int CmdPyramidDemod(const char *Cmd) { } } - PrintAndLogEx(SUCCESS, "Checksum : 0x%02X - %02X - %s" + PrintAndLogEx(DEBUG, "DEBUG: Pyramid: checksum : 0x%02X - %02X - %s" , checksum , checkCS , (checksum == checkCS) ? _GREEN_("Passed") : _RED_("Failed") From 44c3a0a8aada7670278fe432faf909a97bdf99cb Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 24 Mar 2019 19:50:53 +0100 Subject: [PATCH 4/7] chg: 'lf keri demod' - added stopbits --- client/cmdlfkeri.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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); From 19588b045f06e91431cba217ac7b3a0d56144129 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 24 Mar 2019 22:09:25 +0100 Subject: [PATCH 5/7] Fix realloc mistake: ptr nulled but not freed upon failure --- client/cmdflashmem.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 From eb3f5e12ebf0c8bcce2dfe919a9502c917aac745 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 24 Mar 2019 22:20:58 +0100 Subject: [PATCH 6/7] Fix memleak in fpga_compress --- client/fpga_compress.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/fpga_compress.c b/client/fpga_compress.c index cdd899782..960af2c29 100644 --- a/client/fpga_compress.c +++ b/client/fpga_compress.c @@ -429,9 +429,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; From 9d1aa3fb96550c70cf2de38f80275fd31cdf7ae9 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 24 Mar 2019 22:26:49 +0100 Subject: [PATCH 7/7] fgpa_compress: dealloc responsibility to main and add missing one --- client/fpga_compress.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/fpga_compress.c b/client/fpga_compress.c index 960af2c29..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); @@ -478,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); } } }