From: iceman1001 Date: Thu, 29 Jan 2015 20:44:24 +0000 (+0100) Subject: Minor bounds checks for setDemodBuf and printDemodBuff X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/b6bf6528216450eedf1ec44a7c908115006c7949?ds=sidebyside Minor bounds checks for setDemodBuf and printDemodBuff --- diff --git a/client/cmddata.c b/client/cmddata.c index 8c91f0e1..1c4eb5a6 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,11 @@ void printDemodBuff() return; } if (bitLen>512) bitLen=512; //max output to 512 bits if we have more - should be plenty + + // equally divided by 16 + if ( bitLen % 16 > 0) + bitLen = (bitlen/16); + 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],