// CRC Calculations from the software reveng commands
//-----------------------------------------------------------------------------
-#include <stdlib.h>
#ifdef _WIN32
# include <io.h>
# include <fcntl.h>
#include <stdio.h>
#include <string.h>
-//#include <stdlib.h>
-//#include <ctype.h>
+#include <stdlib.h>
+#include <ctype.h>
#include "cmdmain.h"
#include "cmdcrc.h"
#include "reveng/reveng.h"
int wordCnt = 0;
while(1){
- while(isspace(str[beginIndex])){
+ while(isspace((unsigned char)str[beginIndex])){
++beginIndex;
}
- if(str[beginIndex] == '\0')
+ if(str[beginIndex] == '\0') {
break;
- endIndex = beginIndex;
- while (str[endIndex] && !isspace(str[endIndex])){
+ }
+ endIndex = beginIndex;
+ while (str[endIndex] && !isspace((unsigned char)str[endIndex])){
++endIndex;
}
int len = endIndex - beginIndex;
int ibperhx = 8, obperhx = 8;
int rflags = 0; // search flags
int c;
- unsigned long width = 0UL;
+ //unsigned long width;
poly_t apoly, crc;
char *string;
return uerr("no preset models available");
// must set width so that parameter to -ipx is not zeroed
- width = plen(model.spoly);
+ //width = plen(model.spoly);
rflags |= R_HAVEP | R_HAVEI | R_HAVERI | R_HAVERO | R_HAVEX;
//set flags
char result[30];
int dataLen;
char endian = 0;
- dataLen = param_getstr(Cmd, cmdp++, inModel);
+ dataLen = param_getstr(Cmd, cmdp++, inModel, sizeof(inModel));
if (dataLen < 4) return 0;
- dataLen = param_getstr(Cmd, cmdp++, inHexStr);
+ dataLen = param_getstr(Cmd, cmdp++, inHexStr, sizeof(inHexStr));
if (dataLen < 4) return 0;
bool reverse = (param_get8(Cmd, cmdp++)) ? true : false;
endian = param_getchar(Cmd, cmdp++);
// takes hex string in and searches for a matching result (hex string must include checksum)
int CmdrevengSearch(const char *Cmd){
char inHexStr[50] = {0x00};
- int dataLen = param_getstr(Cmd, 0, inHexStr);
+ int dataLen = param_getstr(Cmd, 0, inHexStr, sizeof(inHexStr));
if (dataLen < 4) return 0;
char *Models[80];
if (ans) {
//test for match
if (memcmp(result, inCRC, crcChars)==0){
- PrintAndLog("\nFound a match!\nModel: %s\nValue: %s\n",Models[i], result);
+ PrintAndLog("\nFound a possible match!\nModel: %s\nValue: %s\n",Models[i], result);
//optional - stop searching if found...
found = true;
} else {
if (crcChars > 2){
char *swapEndian = SwapEndianStr(result, crcChars, crcChars);
if (memcmp(swapEndian, inCRC, crcChars)==0){
- PrintAndLog("\nFound a match!\nModel: %s\nValue EndianSwapped: %s\n",Models[i], swapEndian);
+ PrintAndLog("\nFound a possible match!\nModel: %s\nValue EndianSwapped: %s\n",Models[i], swapEndian);
//optional - stop searching if found...
found = true;
}
if (ans) {
//test for match
if (memcmp(revResult, inCRC, crcChars)==0){
- PrintAndLog("\nFound a match!\nModel Reversed: %s\nValue: %s\n",Models[i], revResult);
+ PrintAndLog("\nFound a possible match!\nModel Reversed: %s\nValue: %s\n",Models[i], revResult);
//optional - stop searching if found...
found = true;
} else {
if (crcChars > 2){
char *swapEndian = SwapEndianStr(revResult, crcChars, crcChars);
if (memcmp(swapEndian, inCRC, crcChars)==0){
- PrintAndLog("\nFound a match!\nModel Reversed: %s\nValue EndianSwapped: %s\n",Models[i], swapEndian);
+ PrintAndLog("\nFound a possible match!\nModel Reversed: %s\nValue EndianSwapped: %s\n",Models[i], swapEndian);
//optional - stop searching if found...
found = true;
}