Commit ed82c437 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso

netfilter: xt_TCPOPTSTRIP: don't use tcp_hdr()

In (bc6bcb59 netfilter: xt_TCPOPTSTRIP: fix possible mangling beyond
packet boundary), the use of tcp_hdr was introduced. However, we
cannot assume that skb->transport_header is set for non-local packets.

Cc: Florian Westphal <fw@strlen.de>
Reported-by: default avatarPhil Oester <kernel@linuxace.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent a8241c63
...@@ -48,11 +48,13 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb, ...@@ -48,11 +48,13 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
return NF_DROP; return NF_DROP;
len = skb->len - tcphoff; len = skb->len - tcphoff;
if (len < (int)sizeof(struct tcphdr) || if (len < (int)sizeof(struct tcphdr))
tcp_hdr(skb)->doff * 4 > len)
return NF_DROP; return NF_DROP;
tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff); tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
if (tcph->doff * 4 > len)
return NF_DROP;
opt = (u_int8_t *)tcph; opt = (u_int8_t *)tcph;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment