From 621fffbfbdc3f76d77c12750ae5f9e4fe66ffcbc Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Tue, 18 Sep 2018 10:52:04 +0500 Subject: [PATCH] src/Cedar/Hub.c: resolve null pointer dereference found by coverity, also cleanup a code based on PVS analyzer findings src/Cedar/Hub.c 5279 warn V547 Expression 'e->UpdatedTime <= oldest_time' is always true. src/Cedar/Hub.c 5840 warn V581 The conditional expressions of the 'if' statements situated alongside each other are identical. Check lines: 5828, 5840. --- src/Cedar/Hub.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Cedar/Hub.c b/src/Cedar/Hub.c index 9f6b9dd0..7205546d 100644 --- a/src/Cedar/Hub.c +++ b/src/Cedar/Hub.c @@ -5264,7 +5264,6 @@ bool IsIPManagementTargetForHUB(IP *ip, HUB *hub) void DeleteOldIpTableEntry(LIST *o) { UINT i; - UINT64 oldest_time = 0xffffffffffffffffULL; IP_TABLE_ENTRY *old = NULL; // Validate arguments if (o == NULL) @@ -5275,11 +5274,7 @@ void DeleteOldIpTableEntry(LIST *o) for (i = 0;i < LIST_NUM(o);i++) { IP_TABLE_ENTRY *e = LIST_DATA(o, i); - - if (e->UpdatedTime <= oldest_time) - { - old = e; - } + old = e; } if (old != NULL) @@ -5394,7 +5389,7 @@ void StorePacketToHubPa(HUB_PA *dest, SESSION *src, void *data, UINT size, PKT * } } - if (src != NULL && src->Hub != NULL && src->Hub->Option != NULL && src->Hub->Option->FixForDLinkBPDU) + if (packet != NULL && src != NULL && src->Hub != NULL && src->Hub->Option != NULL && src->Hub->Option->FixForDLinkBPDU) { // Measures for D-Link bug UCHAR *mac = packet->MacAddressSrc; @@ -5840,10 +5835,8 @@ UPDATE_DHCP_ALLOC_ENTRY: DeleteOldIpTableEntry(hub->IpTable); } Insert(hub->IpTable, e); - } - if (new_entry) - { + if ((hub->Option != NULL && hub->Option->NoDhcpPacketLogOutsideHub == false) || mac_table->Session != s) { char dhcp_mac_addr[64];