more coverity fixes

plus fix some spacing in functions i touched.
This commit is contained in:
marshmellow42 2017-06-06 12:45:00 -04:00
commit e57c8b2e56
3 changed files with 117 additions and 114 deletions

View file

@ -656,10 +656,12 @@ int CmdHF14ACmdRaw(const char *cmd) {
sscanf(buf,"%x",&temp); sscanf(buf,"%x",&temp);
data[datalen]=(uint8_t)(temp & 0xff); data[datalen]=(uint8_t)(temp & 0xff);
*buf=0; *buf=0;
if (++datalen>sizeof(data)){ if (datalen > sizeof(data)-1) {
if (crc) if (crc)
PrintAndLog("Buffer is full, we can't add CRC to your data"); PrintAndLog("Buffer is full, we can't add CRC to your data");
break; break;
} else {
datalen++
} }
} }
continue; continue;
@ -709,8 +711,8 @@ int CmdHF14ACmdRaw(const char *cmd) {
c.arg[0] |= ISO14A_TOPAZMODE; c.arg[0] |= ISO14A_TOPAZMODE;
} }
// Max buffer is USB_CMD_DATA_SIZE // Max buffer is USB_CMD_DATA_SIZE (512)
c.arg[1] = (datalen & 0xFFFF) | (numbits << 16); c.arg[1] = (datalen & 0xFFFF) | ((uint32_t)numbits << 16);
memcpy(c.d.asBytes,data,datalen); memcpy(c.d.asBytes,data,datalen);
SendCommand(&c); SendCommand(&c);

View file

@ -970,6 +970,7 @@ int CmdHF14AMfChk(const char *Cmd)
break; break;
default: default:
PrintAndLog("Key type must be A , B or ?"); PrintAndLog("Key type must be A , B or ?");
free(keyBlock);
return 1; return 1;
}; };

View file

@ -91,7 +91,7 @@ int GetWiegandFromPresco(const char *Cmd, uint32_t *sitecode, uint32_t *usercode
if(cmdp == 0) errors = 1; if(cmdp == 0) errors = 1;
//Validations //Validations
if(errors) return -1; if(errors || stringlen == 0) return -1;
if (!hex) { if (!hex) {
for (int index =0; index < strlen(id); ++index) { for (int index =0; index < strlen(id); ++index) {