1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-23 01:49:53 +03:00

Merge PR #718: src/Cedar/BridgeUnix.c: resolve null pointer dereference

This commit is contained in:
Davide Beatrici 2018-09-29 23:30:28 +02:00 committed by GitHub
commit 34f443c0c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 85 additions and 105 deletions

View File

@ -2674,6 +2674,7 @@ bool EthProcessIpPacketInnerIpRaw(ETH *e, PKT *p)
void EthPutPacketLinuxIpRaw(ETH *e, void *data, UINT size) void EthPutPacketLinuxIpRaw(ETH *e, void *data, UINT size)
{ {
PKT *p; PKT *p;
SOCK *s = NULL;
// Validate arguments // Validate arguments
if (e == NULL || data == NULL) if (e == NULL || data == NULL)
{ {
@ -2686,8 +2687,13 @@ void EthPutPacketLinuxIpRaw(ETH *e, void *data, UINT size)
} }
p = ParsePacket(data, 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)) if (IsValidUnicastMacAddress(p->MacAddressSrc))
{ {
@ -2703,9 +2709,6 @@ void EthPutPacketLinuxIpRaw(ETH *e, void *data, UINT size)
return; return;
} }
if (p != NULL)
{
SOCK *s = NULL;
if (p->TypeL3 == L3_IPV4) if (p->TypeL3 == L3_IPV4)
{ {
@ -2788,8 +2791,6 @@ void EthPutPacketLinuxIpRaw(ETH *e, void *data, UINT size)
} }
FreePacket(p); FreePacket(p);
}
Free(data); Free(data);
} }

View File

@ -314,16 +314,9 @@ UINT Count(COUNTER *c)
} }
Lock(c->lock); Lock(c->lock);
{
if (c->Ready == false)
{
ret = 0;
}
else
{ {
ret = c->c; ret = c->c;
} }
}
Unlock(c->lock); Unlock(c->lock);
return ret; return ret;
@ -344,17 +337,10 @@ UINT Inc(COUNTER *c)
} }
Lock(c->lock); Lock(c->lock);
{
if (c->Ready == false)
{
ret = 0;
}
else
{ {
c->c++; c->c++;
ret = c->c; ret = c->c;
} }
}
Unlock(c->lock); Unlock(c->lock);
// KS // KS
@ -379,12 +365,6 @@ UINT Dec(COUNTER *c)
} }
Lock(c->lock); Lock(c->lock);
{
if (c->Ready == false)
{
ret = 0;
}
else
{ {
if (c->c != 0) if (c->c != 0)
{ {
@ -396,7 +376,6 @@ UINT Dec(COUNTER *c)
ret = 0; ret = 0;
} }
} }
}
Unlock(c->lock); Unlock(c->lock);
// KS // KS