defrag: check tracker/packet family in compare

Ticket: 8510

Without this check, in case of a hash collision, and the other
fields are equal, we could end up consider adding an IPv6 packet
to a IPv4 tracker (or vice versa).

Doing so, we end up interpreting an IPv6 packet as an IPv4 one,
and we do not benefit from the bounds checks from ipv4/ipv6 decoder.

(cherry picked from commit 24527d662a)
pull/15433/head
Philippe Antoine 5 months ago committed by Victor Julien
parent 654f5fa64f
commit 97d6fa9e14

@ -440,9 +440,13 @@ static inline int DefragTrackerCompare(DefragTracker *t, Packet *p)
{
uint32_t id;
if (PacketIsIPv4(p)) {
if (t->af != AF_INET)
return 0;
const IPV4Hdr *ip4h = PacketGetIPv4(p);
id = (uint32_t)IPV4_GET_RAW_IPID(ip4h);
} else {
if (t->af != AF_INET6)
return 0;
id = IPV6_EXTHDR_GET_FH_ID(p);
}

Loading…
Cancel
Save