From: iceman1001 <iceman@iuse.se>
Date: Tue, 12 Jan 2016 21:30:22 +0000 (+0100)
Subject: FIX: Coverity, unchecked return value, CID #121292,..
X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/28415b5d902e391b5bbfd615b3a42d8cffbb0ce3?ds=inline

FIX: Coverity, unchecked return value, CID #121292,..
basicallty the flush queue commmand is replaced with clearCommandBuffer();.
---

diff --git a/client/cmdhf14a.c b/client/cmdhf14a.c
index d1952672..6d94d33b 100644
--- a/client/cmdhf14a.c
+++ b/client/cmdhf14a.c
@@ -790,7 +790,8 @@ static command_t CommandTable[] =
 
 int CmdHF14A(const char *Cmd) {
 	// flush
-	WaitForResponseTimeout(CMD_ACK,NULL,100);
+	clearCommandBuffer();
+	//WaitForResponseTimeout(CMD_ACK,NULL,100);
 
 	// parse
 	CmdsParse(CommandTable, Cmd);
diff --git a/client/cmdhfdes.c b/client/cmdhfdes.c
index 1876e5c1..200270f0 100644
--- a/client/cmdhfdes.c
+++ b/client/cmdhfdes.c
@@ -16,11 +16,13 @@ static int CmdHelp(const char *Cmd);
 
 int CmdHFDESReader(const char *Cmd)
 {
-    UsbCommand c  ={CMD_MIFARE_DES_READER, {3, 0x60, 0}};
+    UsbCommand c = { CMD_MIFARE_DES_READER, {3, 0x60, 0} };
     SendCommand(&c);
-
     UsbCommand resp;
-	WaitForResponseTimeout(CMD_ACK,&resp,2000);
+	if (!WaitForResponseTimeout(CMD_ACK,&resp,2000) ){
+		PrintAndLog("Command time-out");
+		return 1;
+	}
     return 0;
 }  
 
@@ -57,7 +59,8 @@ static command_t CommandTable[] =
 int CmdHFDES(const char *Cmd)
 {
     //flush
-    WaitForResponseTimeout(CMD_ACK,NULL,100);
+	clearCommandBuffer();
+    //WaitForResponseTimeout(CMD_ACK,NULL,100);
     CmdsParse(CommandTable, Cmd);
     return 0;
 }
diff --git a/client/cmdhfepa.c b/client/cmdhfepa.c
index ed903cf6..68176bf6 100644
--- a/client/cmdhfepa.c
+++ b/client/cmdhfepa.c
@@ -197,9 +197,10 @@ int CmdHelp(const char *Cmd)
 int CmdHFEPA(const char *Cmd)
 {
 	// flush
-	WaitForResponseTimeout(CMD_ACK,NULL,100);
+	clearCommandBuffer();
+	//WaitForResponseTimeout(CMD_ACK,NULL,100);
 
 	// parse
-  CmdsParse(CommandTable, Cmd);
-  return 0;
+	CmdsParse(CommandTable, Cmd);
+	return 0;
 }
diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c
index 272f1ade..7736b9c5 100644
--- a/client/cmdhfmf.c
+++ b/client/cmdhfmf.c
@@ -2163,7 +2163,8 @@ static command_t CommandTable[] =
 int CmdHFMF(const char *Cmd)
 {
 	// flush
-	WaitForResponseTimeout(CMD_ACK,NULL,100);
+	clearCommandBuffer();
+	//WaitForResponseTimeout(CMD_ACK,NULL,100);
 	CmdsParse(CommandTable, Cmd);
 	return 0;
 }
diff --git a/client/cmdhfmfdes.c b/client/cmdhfmfdes.c
index 4aeeffd9..b8db1cab 100644
--- a/client/cmdhfmfdes.c
+++ b/client/cmdhfmfdes.c
@@ -636,8 +636,7 @@ int CmdHF14ADesAuth(const char *Cmd){
 }
 
 
-static command_t CommandTable[] =
-{
+static command_t CommandTable[] = {
   {"help",		CmdHelp,					1, "This help"},
   {"info",		CmdHF14ADesInfo,			0, "Get MIFARE DesFire information"},
   {"enum",		CmdHF14ADesEnumApplications,0, "Tries enumerate all applications"},
@@ -647,18 +646,17 @@ static command_t CommandTable[] =
   {NULL, NULL, 0, NULL}
 };
 
-int CmdHFMFDes(const char *Cmd)
-{
+int CmdHFMFDes(const char *Cmd) {
    // flush
-   WaitForResponseTimeout(CMD_ACK,NULL,100);
-   CmdsParse(CommandTable, Cmd);
-  return 0;
+	clearCommandBuffer();
+	//WaitForResponseTimeout(CMD_ACK,NULL,100);
+	CmdsParse(CommandTable, Cmd);
+	return 0;
 }
 
-int CmdHelp(const char *Cmd)
-{
-  CmdsHelp(CommandTable);
-  return 0;
+int CmdHelp(const char *Cmd) {
+	CmdsHelp(CommandTable);
+	return 0;
 }
 
 
diff --git a/client/cmdhfmfdesfire.c b/client/cmdhfmfdesfire.c
index f2c53dbf..576792d0 100644
--- a/client/cmdhfmfdesfire.c
+++ b/client/cmdhfmfdesfire.c
@@ -239,7 +239,8 @@ static command_t CommandTable[] =
 
 int CmdHFMFDesfire(const char *Cmd){
     // flush
-    WaitForResponseTimeout(CMD_ACK,NULL,100);
+	clearCommandBuffer();
+    //WaitForResponseTimeout(CMD_ACK,NULL,100);
     CmdsParse(CommandTable, Cmd);
     return 0;
 }
diff --git a/client/cmdhfmfu.c b/client/cmdhfmfu.c
index 7567efb8..c7de6c7d 100644
--- a/client/cmdhfmfu.c
+++ b/client/cmdhfmfu.c
@@ -2025,7 +2025,8 @@ static command_t CommandTable[] =
 };
 
 int CmdHFMFUltra(const char *Cmd){
-	WaitForResponseTimeout(CMD_ACK,NULL,100);
+	clearCommandBuffer();
+	//WaitForResponseTimeout(CMD_ACK,NULL,100);
 	CmdsParse(CommandTable, Cmd);
 	return 0;
 }
diff --git a/client/mifarehost.c b/client/mifarehost.c
index e6ad6016..1cb228bb 100644
--- a/client/mifarehost.c
+++ b/client/mifarehost.c
@@ -79,7 +79,8 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t * key, uint8_t trgBlockNo
 	struct Crypto1State *p1, *p2, *p3, *p4;
 	
 	// flush queue
-	WaitForResponseTimeout(CMD_ACK,NULL,100);
+	clearCommandBuffer();
+	//WaitForResponseTimeout(CMD_ACK,NULL,100);
 	
 	UsbCommand c = {CMD_MIFARE_NESTED, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, calibrate}};
 	memcpy(c.d.asBytes, key, 6);