FIX; coverity scan 133850, & operation should keep only topbit of lower nibble.

CHG: tabs fixed
This commit is contained in:
iceman1001 2016-08-03 10:01:37 +02:00
commit e8fecd72bc

View file

@ -47,24 +47,29 @@ int usage_legic_read(void){
return 0;
}
int usage_legic_sim(void){
return 0;
}
int usage_legic_rawwrite(void){
return 0;
}
int usage_legic_fill(void){
return 0;
}
/*
* Output BigBuf and deobfuscate LEGIC RF tag data.
* This is based on information given in the talk held
* by Henryk Ploetz and Karsten Nohl at 26c3
*/
int CmdLegicDecode(const char *Cmd) {
// Index for the bytearray.
int i = 0;
int k = 0, segmentNum;
int segment_len = 0;
int segment_flag = 0;
int i = 0, k = 0, segmentNum = 0, segment_len = 0, segment_flag = 0;
int crc = 0, wrp = 0, wrc = 0;
uint8_t stamp_len = 0;
int crc = 0;
int wrp = 0;
int wrc = 0;
uint8_t data_buf[1052]; // receiver buffer, should be 1024..
char token_type[5];
int dcf;
uint8_t data_buf[1052]; // receiver buffer
char token_type[5] = {0,0,0,0,0};
int dcf = 0;
int bIsSegmented = 0;
// download EML memory, where the "legic read" command puts the data.
@ -181,12 +186,10 @@ int CmdLegicDecode(const char *Cmd) {
}
}
uint8_t segCrcBytes[8] = {0x00};
uint8_t segCrcBytes[8] = {0,0,0,0,0,0,0,0};
uint32_t segCalcCRC = 0;
uint32_t segCRC = 0;
// Data card?
if(dcf <= 60000) {
@ -297,7 +300,7 @@ int CmdLegicDecode(const char *Cmd) {
i = 8;
wrp = data_buf[7] & 0x0F;
wrc = (data_buf[7] & 0x07) >> 4; // ICEMAN 20160802, this will always be ZERO
wrc = (data_buf[7] & 0x707) >> 4;
bool hasWRC = (wrc > 0);
bool hasWRP = (wrp > wrc);
@ -362,8 +365,10 @@ int CmdLegicRFRead(const char *Cmd) {
return 0;
}
int CmdLegicLoad(const char *Cmd) {
// iceman: potential bug, where all filepaths or filename which starts with H or h will print the helptext :)
char cmdp = param_getchar(Cmd, 0);
if ( cmdp == 'H' || cmdp == 'h' || cmdp == 0x00) return usage_legic_load();
@ -444,9 +449,11 @@ int CmdLegicSave(const char *Cmd) {
int requested = 1024;
int offset = 0;
int delivered = 0;
char filename[FILE_PATH_SIZE];
char filename[FILE_PATH_SIZE] = {0x00};
uint8_t got[1024] = {0x00};
memset(filename, 0, FILE_PATH_SIZE);
sscanf(Cmd, " %s %i %i", filename, &requested, &offset);
/* If no length given save entire legic read buffer */
@ -501,7 +508,7 @@ int CmdLegicRfSim(const char *Cmd) {
//TODO: write a help text (iceman)
int CmdLegicRfWrite(const char *Cmd) {
UsbCommand c = {CMD_WRITER_LEGIC_RF};
UsbCommand c = {CMD_WRITER_LEGIC_RF, {0,0,0}};
int res = sscanf(Cmd, " 0x%"llx" 0x%"llx, &c.arg[0], &c.arg[1]);
if(res != 2) {
PrintAndLog("Please specify the offset and length as two hex strings");