mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-20 23:36:31 +08:00
Fixed several issues found using a coverity-scan
This commit is contained in:
parent
77dfaa26db
commit
90e278d3da
|
@ -556,7 +556,7 @@ int CmdManchesterDemod(const char *Cmd)
|
||||||
|
|
||||||
/* But it does not work if compiling on WIndows: therefore we just allocate a */
|
/* But it does not work if compiling on WIndows: therefore we just allocate a */
|
||||||
/* large array */
|
/* large array */
|
||||||
uint8_t BitStream[MAX_GRAPH_TRACE_LEN];
|
uint8_t BitStream[MAX_GRAPH_TRACE_LEN] = {0};
|
||||||
|
|
||||||
/* Detect high and lows */
|
/* Detect high and lows */
|
||||||
for (i = 0; i < GraphTraceLen; i++)
|
for (i = 0; i < GraphTraceLen; i++)
|
||||||
|
|
|
@ -535,7 +535,8 @@ int CmdHF15CmdRaw (const char *cmd) {
|
||||||
*/
|
*/
|
||||||
int prepareHF15Cmd(char **cmd, UsbCommand *c, uint8_t iso15cmd[], int iso15cmdlen) {
|
int prepareHF15Cmd(char **cmd, UsbCommand *c, uint8_t iso15cmd[], int iso15cmdlen) {
|
||||||
int temp;
|
int temp;
|
||||||
uint8_t *req=c->d.asBytes, uid[8];
|
uint8_t *req=c->d.asBytes;
|
||||||
|
uint8_t uid[8] = {0};
|
||||||
uint32_t reqlen=0;
|
uint32_t reqlen=0;
|
||||||
|
|
||||||
// strip
|
// strip
|
||||||
|
|
|
@ -502,6 +502,8 @@ int CmdHFiClassReader_Dump(const char *Cmd)
|
||||||
SendCommand(&c);
|
SendCommand(&c);
|
||||||
|
|
||||||
UsbCommand resp;
|
UsbCommand resp;
|
||||||
|
uint8_t key_sel[8] = {0};
|
||||||
|
uint8_t key_sel_p[8] = { 0 };
|
||||||
|
|
||||||
if (WaitForResponseTimeout(CMD_ACK,&resp,4500)) {
|
if (WaitForResponseTimeout(CMD_ACK,&resp,4500)) {
|
||||||
uint8_t isOK = resp.arg[0] & 0xff;
|
uint8_t isOK = resp.arg[0] & 0xff;
|
||||||
|
@ -520,8 +522,6 @@ int CmdHFiClassReader_Dump(const char *Cmd)
|
||||||
{
|
{
|
||||||
if(elite)
|
if(elite)
|
||||||
{
|
{
|
||||||
uint8_t key_sel[8] = {0};
|
|
||||||
uint8_t key_sel_p[8] = { 0 };
|
|
||||||
//Get the key index (hash1)
|
//Get the key index (hash1)
|
||||||
uint8_t key_index[8] = {0};
|
uint8_t key_index[8] = {0};
|
||||||
|
|
||||||
|
|
|
@ -1004,6 +1004,16 @@ int CmdHF14AMfNested(const char *Cmd)
|
||||||
|
|
||||||
int CmdHF14AMfChk(const char *Cmd)
|
int CmdHF14AMfChk(const char *Cmd)
|
||||||
{
|
{
|
||||||
|
if (strlen(Cmd)<3) {
|
||||||
|
PrintAndLog("Usage: hf mf chk <block number>|<*card memory> <key type (A/B/?)> [t] [<key (12 hex symbols)>] [<dic (*.dic)>]");
|
||||||
|
PrintAndLog(" * - all sectors");
|
||||||
|
PrintAndLog("card memory - 0 - MINI(320 bytes), 1 - 1K, 2 - 2K, 4 - 4K, <other> - 1K");
|
||||||
|
PrintAndLog("d - write keys to binary file\n");
|
||||||
|
PrintAndLog(" sample: hf mf chk 0 A 1234567890ab keys.dic");
|
||||||
|
PrintAndLog(" hf mf chk *1 ? t");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
FILE * f;
|
FILE * f;
|
||||||
char filename[256]={0};
|
char filename[256]={0};
|
||||||
char buf[13];
|
char buf[13];
|
||||||
|
@ -1021,6 +1031,7 @@ int CmdHF14AMfChk(const char *Cmd)
|
||||||
int transferToEml = 0;
|
int transferToEml = 0;
|
||||||
int createDumpFile = 0;
|
int createDumpFile = 0;
|
||||||
|
|
||||||
|
|
||||||
keyBlock = calloc(stKeyBlock, 6);
|
keyBlock = calloc(stKeyBlock, 6);
|
||||||
if (keyBlock == NULL) return 1;
|
if (keyBlock == NULL) return 1;
|
||||||
|
|
||||||
|
@ -1047,15 +1058,6 @@ int CmdHF14AMfChk(const char *Cmd)
|
||||||
num_to_bytes(defaultKeys[defaultKeyCounter], 6, (uint8_t*)(keyBlock + defaultKeyCounter * 6));
|
num_to_bytes(defaultKeys[defaultKeyCounter], 6, (uint8_t*)(keyBlock + defaultKeyCounter * 6));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(Cmd)<3) {
|
|
||||||
PrintAndLog("Usage: hf mf chk <block number>|<*card memory> <key type (A/B/?)> [t] [<key (12 hex symbols)>] [<dic (*.dic)>]");
|
|
||||||
PrintAndLog(" * - all sectors");
|
|
||||||
PrintAndLog("card memory - 0 - MINI(320 bytes), 1 - 1K, 2 - 2K, 4 - 4K, <other> - 1K");
|
|
||||||
PrintAndLog("d - write keys to binary file\n");
|
|
||||||
PrintAndLog(" sample: hf mf chk 0 A 1234567890ab keys.dic");
|
|
||||||
PrintAndLog(" hf mf chk *1 ? t");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (param_getchar(Cmd, 0)=='*') {
|
if (param_getchar(Cmd, 0)=='*') {
|
||||||
blockNo = 3;
|
blockNo = 3;
|
||||||
|
@ -1144,11 +1146,11 @@ int CmdHF14AMfChk(const char *Cmd)
|
||||||
keycnt++;
|
keycnt++;
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
}
|
}
|
||||||
|
fclose(f);
|
||||||
} else {
|
} else {
|
||||||
PrintAndLog("File: %s: not found or locked.", filename);
|
PrintAndLog("File: %s: not found or locked.", filename);
|
||||||
free(keyBlock);
|
free(keyBlock);
|
||||||
return 1;
|
return 1;
|
||||||
fclose(f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1586,8 +1588,8 @@ int CmdHF14AMfEKeyPrn(const char *Cmd)
|
||||||
int CmdHF14AMfCSetUID(const char *Cmd)
|
int CmdHF14AMfCSetUID(const char *Cmd)
|
||||||
{
|
{
|
||||||
uint8_t wipeCard = 0;
|
uint8_t wipeCard = 0;
|
||||||
uint8_t uid[8];
|
uint8_t uid[8] = {0};
|
||||||
uint8_t oldUid[8];
|
uint8_t oldUid[8]= {0};
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (strlen(Cmd) < 1 || param_getchar(Cmd, 0) == 'h') {
|
if (strlen(Cmd) < 1 || param_getchar(Cmd, 0) == 'h') {
|
||||||
|
|
|
@ -319,7 +319,7 @@ int CmdEM4x50Read(const char *Cmd)
|
||||||
++i;
|
++i;
|
||||||
while ((GraphBuffer[i] > low) && (i<GraphTraceLen))
|
while ((GraphBuffer[i] > low) && (i<GraphTraceLen))
|
||||||
++i;
|
++i;
|
||||||
if (j>(MAX_GRAPH_TRACE_LEN/64)) {
|
if (j>=(MAX_GRAPH_TRACE_LEN/64)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tmpbuff[j++]= i - start;
|
tmpbuff[j++]= i - start;
|
||||||
|
|
|
@ -149,6 +149,7 @@ int CmdLFHitagSim(const char *Cmd) {
|
||||||
tag_mem_supplied = true;
|
tag_mem_supplied = true;
|
||||||
if (fread(c.d.asBytes,48,1,pf) == 0) {
|
if (fread(c.d.asBytes,48,1,pf) == 0) {
|
||||||
PrintAndLog("Error: File reading error");
|
PrintAndLog("Error: File reading error");
|
||||||
|
fclose(pf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
fclose(pf);
|
fclose(pf);
|
||||||
|
|
|
@ -134,8 +134,9 @@ int getCommand(UsbCommand* response)
|
||||||
*/
|
*/
|
||||||
bool WaitForResponseTimeout(uint32_t cmd, UsbCommand* response, size_t ms_timeout) {
|
bool WaitForResponseTimeout(uint32_t cmd, UsbCommand* response, size_t ms_timeout) {
|
||||||
|
|
||||||
|
UsbCommand resp;
|
||||||
|
|
||||||
if (response == NULL) {
|
if (response == NULL) {
|
||||||
UsbCommand resp;
|
|
||||||
response = &resp;
|
response = &resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -296,7 +296,7 @@ static uint8_t trailerAccessBytes[4] = {0x08, 0x77, 0x8F, 0x00};
|
||||||
// variables
|
// variables
|
||||||
char logHexFileName[200] = {0x00};
|
char logHexFileName[200] = {0x00};
|
||||||
static uint8_t traceCard[4096] = {0x00};
|
static uint8_t traceCard[4096] = {0x00};
|
||||||
static char traceFileName[20];
|
static char traceFileName[200] = {0};
|
||||||
static int traceState = TRACE_IDLE;
|
static int traceState = TRACE_IDLE;
|
||||||
static uint8_t traceCurBlock = 0;
|
static uint8_t traceCurBlock = 0;
|
||||||
static uint8_t traceCurKey = 0;
|
static uint8_t traceCurKey = 0;
|
||||||
|
|
|
@ -544,8 +544,14 @@ lfsr_common_prefix(uint32_t pfx, uint32_t rr, uint8_t ks[8], uint8_t par[8][8],
|
||||||
|
|
||||||
statelist = malloc((sizeof *statelist) << 21); //how large should be?
|
statelist = malloc((sizeof *statelist) << 21); //how large should be?
|
||||||
if(!statelist || !odd || !even)
|
if(!statelist || !odd || !even)
|
||||||
|
{
|
||||||
|
free(statelist);
|
||||||
|
free(odd);
|
||||||
|
free(even);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
s = statelist;
|
s = statelist;
|
||||||
for(o = odd; *o != -1; ++o)
|
for(o = odd; *o != -1; ++o)
|
||||||
for(e = even; *e != -1; ++e)
|
for(e = even; *e != -1; ++e)
|
||||||
|
|
Loading…
Reference in a new issue