Skip to content

Commit

Permalink
Bugfix 22641 in oss-fuzz: Out-of-memory in FuzzTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
seladb committed May 30, 2020
1 parent 994419f commit 0a62fd3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Packet++/src/BgpLayer.cpp
Expand Up @@ -34,6 +34,10 @@ BgpLayer* BgpLayer::parseBgpLayer(uint8_t* data, size_t dataLen, Layer* prevLaye
return NULL;

bgp_common_header* bgpHeader = (bgp_common_header*)data;

// illegal header data - length is too small
if (be16toh(bgpHeader->length) < static_cast<uint16_t>(sizeof(bgp_common_header)))
return NULL;

switch (bgpHeader->messageType)
{
Expand Down Expand Up @@ -74,7 +78,7 @@ std::string BgpLayer::getMessageTypeAsString() const
void BgpLayer::parseNextLayer()
{
size_t headerLen = getHeaderLen();
if (m_DataLen <= headerLen)
if (m_DataLen <= headerLen || headerLen == 0)
return;

uint8_t* payload = m_Data + headerLen;
Expand Down
Binary file not shown.

0 comments on commit 0a62fd3

Please sign in to comment.