Skip to content

Commit

Permalink
Bugfix 22084 in oss-fuzz: Use-of-uninitialized-value in pcpp::NullLoo…
Browse files Browse the repository at this point in the history
…pbackLayer::getFamily
  • Loading branch information
seladb committed May 27, 2020
1 parent 3e0078c commit 46840c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Packet++/src/Packet.cpp
Expand Up @@ -80,7 +80,7 @@ void Packet::setRawPacket(RawPacket* rawPacket, bool freeRawPacket, ProtocolType
m_LastLayer->m_NextLayer = NULL;
}

if (parseUntil == UnknownProtocol && parseUntilLayer == OsiModelLayerUnknown)
if (m_LastLayer != NULL && parseUntil == UnknownProtocol && parseUntilLayer == OsiModelLayerUnknown)
{
// find if there is data left in the raw packet that doesn't belong to any layer. In that case it's probably a packet trailer.
// create a PacketTrailerLayer layer and add it at the end of the packet
Expand Down Expand Up @@ -679,6 +679,9 @@ std::string Packet::printPacketInfo(bool timeAsLocalTime) const
Layer* Packet::createFirstLayer(LinkLayerType linkType)
{
size_t rawDataLen = (size_t)m_RawPacket->getRawDataLen();
if (rawDataLen == 0)
return NULL;

const uint8_t* rawData = m_RawPacket->getRawData();

if (linkType == LINKTYPE_ETHERNET)
Expand Down
Binary file not shown.

0 comments on commit 46840c6

Please sign in to comment.