Check for valid ip_hdr length before trying to make a Val out of it

This commit is contained in:
Tim Wojtulewicz 2022-08-12 15:01:37 -07:00
parent 8d7a156109
commit b9f63173bc
3 changed files with 14 additions and 2 deletions

View file

@ -142,7 +142,7 @@ RecordValPtr Packet::ToRawPktHdrVal() const
pkt_hdr->Assign(0, std::move(l2_hdr));
if ( l3_proto == L3_IPV4 || l3_proto == L3_IPV6 )
if ( ip_hdr && cap_len >= ip_hdr->TotalLen() && (l3_proto == L3_IPV4 || l3_proto == L3_IPV6) )
// Packet analysis will have stored the IP header in the packet, so we can use
// that to build the output.
return ip_hdr->ToPktHdrVal(std::move(pkt_hdr), 1);