Browse Source

Merge PR #1276: fix several issues found by Coverity

Davide Beatrici 4 years ago
parent
commit
5ed11a0270
1 changed files with 7 additions and 11 deletions
  1. 7 11
      src/Cedar/Proto_PPP.c

+ 7 - 11
src/Cedar/Proto_PPP.c

@@ -721,6 +721,12 @@ bool PPPProcessRetransmissions(PPP_SESSION *p)
 // Send the PPP Echo Request
 bool PPPSendEchoRequest(PPP_SESSION *p)
 {
+	// Validate arguments
+	if (p == NULL)
+	{
+		return false;
+	}
+
 	UINT64 now = Tick64();
 	if (p->NextEchoSendTime == 0 || now >= p->NextEchoSendTime)
 	{
@@ -733,12 +739,6 @@ bool PPPSendEchoRequest(PPP_SESSION *p)
 			AddInterrupt(p->Ipc->Interrupt, p->NextEchoSendTime);
 		}
 
-		// Validate arguments
-		if (p == NULL)
-		{
-			return false;
-		}
-
 		pp = ZeroMalloc(sizeof(PPP_PACKET));
 		pp->Protocol = PPP_PROTOCOL_LCP;
 		pp->IsControl = true;
@@ -2573,10 +2573,6 @@ PPP_PACKET *ParsePPPPacket(void *data, UINT size)
 	buf = (UCHAR *)data;
 
 	// Address
-	if (size < 1)
-	{
-		goto LABEL_ERROR;
-	}
 	if (buf[0] != 0xff)
 	{
 		goto LABEL_ERROR;
@@ -3745,7 +3741,7 @@ bool PPPParseUsername(CEDAR *cedar, char *src_username, ETHERIP_ID *dst)
 	char src[MAX_SIZE];
 	// Validate arguments
 	Zero(dst, sizeof(ETHERIP_ID));
-	if (cedar == NULL || src == NULL || dst == NULL)
+	if (cedar == NULL || dst == NULL)
 	{
 		return false;
 	}