src/Cedar/BridgeUnix.c: resolve null pointer dereference
found by coverity
@@ -2676,6 +2676,7 @@ bool EthProcessIpPacketInnerIpRaw(ETH *e, PKT *p)
void EthPutPacketLinuxIpRaw(ETH *e, void *data, UINT size)
{
PKT *p;
+ SOCK *s = NULL;
// Validate arguments
if (e == NULL || data == NULL)
{
@@ -2688,8 +2689,13 @@ void EthPutPacketLinuxIpRaw(ETH *e, void *data, UINT size)
}
p = ParsePacket(data, size);
+ if (p == NULL)
+ {
+ Free(data);
+ return;
+ }
- if (p != NULL && (p->BroadcastPacket || Cmp(p->MacAddressDest, e->RawIpMyMacAddr, 6) == 0))
+ if (p->BroadcastPacket || Cmp(p->MacAddressDest, e->RawIpMyMacAddr, 6) == 0)
{
if (IsValidUnicastMacAddress(p->MacAddressSrc))
{
@@ -2705,9 +2711,6 @@ void EthPutPacketLinuxIpRaw(ETH *e, void *data, UINT size)
return;
}
- if (p != NULL)
- {
- SOCK *s = NULL;
if (p->TypeL3 == L3_IPV4)
{
@@ -2790,8 +2793,6 @@ void EthPutPacketLinuxIpRaw(ETH *e, void *data, UINT size)
}
FreePacket(p);
- }
-
Free(data);
}
