1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 17:39:53 +03:00

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.
This commit is contained in:
Ilya Shipitsin 2018-09-18 10:52:04 +05:00
parent 93c962fb68
commit 621fffbfbd

View File

@ -5264,7 +5264,6 @@ bool IsIPManagementTargetForHUB(IP *ip, HUB *hub)
void DeleteOldIpTableEntry(LIST *o) void DeleteOldIpTableEntry(LIST *o)
{ {
UINT i; UINT i;
UINT64 oldest_time = 0xffffffffffffffffULL;
IP_TABLE_ENTRY *old = NULL; IP_TABLE_ENTRY *old = NULL;
// Validate arguments // Validate arguments
if (o == NULL) if (o == NULL)
@ -5275,11 +5274,7 @@ void DeleteOldIpTableEntry(LIST *o)
for (i = 0;i < LIST_NUM(o);i++) for (i = 0;i < LIST_NUM(o);i++)
{ {
IP_TABLE_ENTRY *e = LIST_DATA(o, i); IP_TABLE_ENTRY *e = LIST_DATA(o, i);
old = e;
if (e->UpdatedTime <= oldest_time)
{
old = e;
}
} }
if (old != NULL) 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 // Measures for D-Link bug
UCHAR *mac = packet->MacAddressSrc; UCHAR *mac = packet->MacAddressSrc;
@ -5840,10 +5835,8 @@ UPDATE_DHCP_ALLOC_ENTRY:
DeleteOldIpTableEntry(hub->IpTable); DeleteOldIpTableEntry(hub->IpTable);
} }
Insert(hub->IpTable, e); Insert(hub->IpTable, e);
}
if (new_entry)
{
if ((hub->Option != NULL && hub->Option->NoDhcpPacketLogOutsideHub == false) || mac_table->Session != s) if ((hub->Option != NULL && hub->Option->NoDhcpPacketLogOutsideHub == false) || mac_table->Session != s)
{ {
char dhcp_mac_addr[64]; char dhcp_mac_addr[64];