From a08857150b6be7b4dec519f6810b5395e361e305 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Wed, 24 Feb 2021 00:04:52 +0500 Subject: [PATCH 1/3] cleanup redundant check found by Coverity CID 287561 (#1 of 1): Array compared against 0 (NO_EFFECT)array_null: Comparing an array to null is not useful: src == NULL, since the test will always evaluate as true. Was src formerly declared as a pointer? 3748 if (cedar == NULL || src == NULL || dst == NULL) 3749 { 3750 return false; 3751 } --- src/Cedar/Proto_PPP.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cedar/Proto_PPP.c b/src/Cedar/Proto_PPP.c index 60103db6..ef27ed3a 100644 --- a/src/Cedar/Proto_PPP.c +++ b/src/Cedar/Proto_PPP.c @@ -3745,7 +3745,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; } From 2715d80e18bbc97508e25dbf05987ff9999acc0a Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Wed, 24 Feb 2021 00:26:44 +0500 Subject: [PATCH 2/3] fix potential null pointer dereference found by Coverity CID 355460 (#1 of 1): Dereference before null check (REVERSE_INULL)check_after_deref: Null-checking p suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 737 if (p == NULL) 738 { 739 return false; 740 } --- src/Cedar/Proto_PPP.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Cedar/Proto_PPP.c b/src/Cedar/Proto_PPP.c index ef27ed3a..6ad76a2e 100644 --- a/src/Cedar/Proto_PPP.c +++ b/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; From 5c346ef96e44e075fade0219bf3b8e5d1ee84011 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Wed, 24 Feb 2021 00:35:17 +0500 Subject: [PATCH 3/3] remove dead code found by Coverity 2575 // Address at_least: At condition size < 1U, the value of size must be at least 1. cannot_single: At condition size < 1U, the value of size cannot be equal to 0. dead_error_condition: The condition size < 1U cannot be true. 2576 if (size < 1) 2577 { CID 287533 (#1 of 1): Logically dead code (DEADCODE)dead_error_line: Execution cannot reach this statement: goto LABEL_ERROR;. 2578 goto LABEL_ERROR; 2579 } --- src/Cedar/Proto_PPP.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Cedar/Proto_PPP.c b/src/Cedar/Proto_PPP.c index 6ad76a2e..9542cf09 100644 --- a/src/Cedar/Proto_PPP.c +++ b/src/Cedar/Proto_PPP.c @@ -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;