From 252467f956d9d94aec263127885bc7ca8d99080a Mon Sep 17 00:00:00 2001 From: Michal Zima Date: Sat, 15 Jun 2013 16:33:03 +0200 Subject: [PATCH] Better way to filter out IPv4 flags --- src/tcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tcp.c b/src/tcp.c index ca2caea..b178098 100644 --- a/src/tcp.c +++ b/src/tcp.c @@ -67,7 +67,7 @@ int tcp_ipv4(struct s_ethernet *eth4, struct s_ipv4 *ip4, char *payload, if ((ip4->flags_offset | htons(IPV4_FLAG_DONT_FRAGMENT)) == htons(IPV4_FLAG_DONT_FRAGMENT) || ((ip4->flags_offset & htons(IPV4_FLAG_MORE_FRAGMENTS)) && - (ip4->flags_offset & 0xff1f) == 0x0000 && + (ip4->flags_offset & htons(0x1fff)) == 0x0000 && payload_size >= sizeof(struct s_tcp))) { /* parse TCP header */ tcp = (struct s_tcp *) payload; @@ -398,7 +398,7 @@ int tcp_ipv4(struct s_ethernet *eth4, struct s_ipv4 *ip4, char *payload, sizeof(struct s_ipv6_fragment) - FRAGMENT_LEN); frag->offset_flag = htons(((htons(ip4->flags_offset) & - 0xfffc) + + 0x1fff) + FRAGMENT_LEN / 8) << 3); if (ip4->flags_offset & htons(IPV4_FLAG_MORE_FRAGMENTS)) {