Skip to content

Commit 060df2a

Browse files
authored
Fix silent cast of ProtocolTypeFamily to ProtocolType in Packet ctor. (#2099)
* Change full packet signature to take protocol family instead of protocol type. * Update fix to have a new constructor instead.
1 parent 12524f2 commit 060df2a

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

Packet++/header/Packet.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ namespace pcpp
9494
explicit Packet(RawPacket* rawPacket, bool freeRawPacket = false, ProtocolType parseUntil = UnknownProtocol,
9595
OsiModelLayer parseUntilLayer = OsiModelLayerUnknown);
9696

97+
/// @copydoc Packet(RawPacket*, bool, ProtocolType, OsiModelLayer)
98+
explicit Packet(RawPacket* rawPacket, bool freeRawPacket, ProtocolTypeFamily parseUntil,
99+
OsiModelLayer parseUntilLayer = OsiModelLayerUnknown);
100+
97101
/// A constructor for creating a packet out of already allocated RawPacket. Very useful when parsing packets
98102
/// that came from the network. When using this constructor a pointer to the RawPacket is saved (data isn't
99103
/// copied) and the RawPacket is parsed, meaning all layers are created and linked to each other in the right

Packet++/src/Packet.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ namespace pcpp
196196
}
197197

198198
Packet::Packet(RawPacket* rawPacket, bool freeRawPacket, ProtocolType parseUntil, OsiModelLayer parseUntilLayer)
199+
: Packet(rawPacket, freeRawPacket, static_cast<ProtocolTypeFamily>(parseUntil), parseUntilLayer)
200+
{}
201+
202+
Packet::Packet(RawPacket* rawPacket, bool freeRawPacket, ProtocolTypeFamily parseUntil,
203+
OsiModelLayer parseUntilLayer)
199204
{
200205
m_FreeRawPacket = false;
201206
m_RawPacket = nullptr;

0 commit comments

Comments
 (0)