X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/f71f4deb8f8f1e932c81f3e62e6ab67012e07b33..e57fe796f529d3edd7d48f1fa51676e809531280:/client/cmddata.c

diff --git a/client/cmddata.c b/client/cmddata.c
index 8c91f0e1..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],