diff --git a/CHANGELOG.md b/CHANGELOG.md index c1fd2dd8d..0b7fbba9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] +- Fixed `hf texkom reader -v` - now no ovewflow in the general decoder (@iceman1001) - Changed `trace list` - the Hitag U and Hitag S annotators now build their text with the `strlen()` offset (@iceman1001) - Fixed `hf felica` - the service code footer wrote its closing bar past the end of a 128 byte buffer (@iceman1001) - Fixed `trace list` - a Hitag U LOGIN or WRITE SINGLE BLOCK frame could write up to 17 bytes past the end of the 60 byte annotation buffer (@iceman1001) diff --git a/client/src/cmdhftexkom.c b/client/src/cmdhftexkom.c index 8a6cee6f2..6efaeebc6 100644 --- a/client/src/cmdhftexkom.c +++ b/client/src/cmdhftexkom.c @@ -30,6 +30,8 @@ #include "graph.h" #define TEXKOM_NOISE_THRESHOLD (10) +#define TEXKOM_BITSTRING_SIZE 256 +#define TEXKOM_MAX_INTERVALS (TEXKOM_BITSTRING_SIZE - 1) static inline uint32_t GetGraphBuffer(uint32_t indx) { if (g_GraphBuffer[indx] < -128) @@ -461,9 +463,9 @@ static int texkom_get_type(texkom_card_select_t *card, bool verbose) { } // decode samples to 8 bytes - char bitstring[256] = {0}; + char bitstring[TEXKOM_BITSTRING_SIZE] = {0}; char cbitstring[128] = {0}; - char genbitstring[256] = {0}; + char genbitstring[TEXKOM_BITSTRING_SIZE] = {0}; int found = TexkomModError; uint32_t sindx = 0; @@ -493,7 +495,7 @@ static int texkom_get_type(texkom_card_select_t *card, bool verbose) { noiselvl = TEXKOM_NOISE_THRESHOLD; } - uint32_t implengths[256] = { 0 }; + uint32_t implengths[TEXKOM_BITSTRING_SIZE] = { 0 }; uint32_t implengthslen = 0; uint32_t impulseindx = 0; uint32_t impulsecnt = 0; @@ -502,7 +504,7 @@ static int texkom_get_type(texkom_card_select_t *card, bool verbose) { impulsecnt++; if (impulseindx != 0) { - if (implengthslen < 256) { + if (implengthslen < TEXKOM_MAX_INTERVALS) { implengths[implengthslen++] = sindx + i - impulseindx; } } @@ -678,9 +680,9 @@ static int CmdHFTexkomReader(const char *Cmd) { } } - char bitstring[256] = {0}; + char bitstring[TEXKOM_BITSTRING_SIZE] = {0}; char cbitstring[128] = {0}; - char genbitstring[256] = {0}; + char genbitstring[TEXKOM_BITSTRING_SIZE] = {0}; int codefound = TexkomModError; uint32_t sindx = 0; while (sindx < samplesCount - 5) { @@ -707,7 +709,7 @@ static int CmdHFTexkomReader(const char *Cmd) { //PrintAndLogEx(WARNING, "--- indx: %d, len: %d, max: %d, noise: %d", sindx, slen, maxlvl, noiselvl); - uint32_t implengths[256] = { 0 }; + uint32_t implengths[TEXKOM_BITSTRING_SIZE] = { 0 }; uint32_t implengthslen = 0; uint32_t impulseindx = 0; uint32_t impulsecnt = 0; @@ -716,7 +718,7 @@ static int CmdHFTexkomReader(const char *Cmd) { impulsecnt++; if (impulseindx != 0) { - if (implengthslen < 256) + if (implengthslen < TEXKOM_MAX_INTERVALS) implengths[implengthslen++] = sindx + i - impulseindx; } impulseindx = sindx + i;