X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/936e0729f9a4d62452e422a87ea372edd39ef165..908536d1616e4953db6fe43de8a6b0cac1972b9a:/client/cmddata.c diff --git a/client/cmddata.c b/client/cmddata.c index 79ff93be..533caeb5 100644 --- a/client/cmddata.c +++ b/client/cmddata.c @@ -30,6 +30,12 @@ static int CmdHelp(const char *Cmd); //by marshmellow void setDemodBuf(uint8_t *buff, size_t size, size_t startIdx) { + if (buff == NULL) + return; + + if ( size >= MAX_DEMOD_BUF_LEN) + size = MAX_DEMOD_BUF_LEN; + size_t i = 0; for (; i < size; i++){ DemodBuffer[i]=buff[startIdx++]; @@ -56,6 +62,10 @@ void printDemodBuff() return; } if (bitLen>512) bitLen=512; //max output to 512 bits if we have more - should be plenty + + // ensure equally divided by 16 + bitLen &= 0xfff0; + for (i = 0; i <= (bitLen-16); i+=16) { PrintAndLog("%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i", DemodBuffer[i], @@ -188,6 +198,11 @@ void printBitStream(uint8_t BitStream[], uint32_t bitLen) return; } if (bitLen>512) bitLen=512; + + // ensure equally divided by 16 + bitLen &= 0xfff0; + + for (i = 0; i <= (bitLen-16); i+=16) { PrintAndLog("%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i", BitStream[i], @@ -1426,7 +1441,7 @@ int CmdHexsamples(const char *Cmd) int offset = 0; char string_buf[25]; char* string_ptr = string_buf; - uint8_t got[40000]; + uint8_t got[BIGBUF_SIZE]; sscanf(Cmd, "%i %i", &requested, &offset); @@ -1435,7 +1450,7 @@ int CmdHexsamples(const char *Cmd) requested = 8; } if (offset + requested > sizeof(got)) { - PrintAndLog("Tried to read past end of buffer, + > 40000"); + PrintAndLog("Tried to read past end of buffer, + > %d", BIGBUF_SIZE); return 0; } @@ -1485,7 +1500,7 @@ int CmdHpf(const char *Cmd) int CmdSamples(const char *Cmd) { - uint8_t got[40000] = {0x00}; + uint8_t got[BIGBUF_SIZE] = {0x00}; int n = strtol(Cmd, NULL, 0); if (n == 0) @@ -1495,14 +1510,14 @@ int CmdSamples(const char *Cmd) n = sizeof(got); PrintAndLog("Reading %d samples from device memory\n", n); - GetFromBigBuf(got,n,0); - WaitForResponse(CMD_ACK,NULL); + GetFromBigBuf(got,n,0); + WaitForResponse(CMD_ACK,NULL); for (int j = 0; j < n; j++) { GraphBuffer[j] = ((int)got[j]) - 128; - } - GraphTraceLen = n; - RepaintGraphWindow(); - return 0; + } + GraphTraceLen = n; + RepaintGraphWindow(); + return 0; } int CmdTuneSamples(const char *Cmd)