diff options
author | Wei Yongjun <yjwei@cn.fujitsu.com> | 2008-07-26 06:59:10 -0400 |
---|---|---|
committer | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2008-07-26 06:59:10 -0400 |
commit | 18e1d836002ad970f42736bad09b7be9cfe99545 (patch) | |
tree | 2e704da1e24eba0f1a09d4b983a34bcc5b51f29d | |
parent | e0bcfb0c6a6ed9ebd68746b306298dc5797fd426 (diff) |
dccp: Fix incorrect length check for ICMPv4 packets
Unlike TCP, which only needs 8 octets of original packet data, DCCP requires
minimally 12 or 16 bytes for ICMP-payload sequence number checks.
This patch replaces the insufficient length constant of 8 with a two-stage
test, making sure that 12 bytes are available, before computing the basic
header length required for sequence number checks.
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
-rw-r--r-- | net/dccp/ipv4.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 6a2f1879e183..882c5c4de69e 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -196,8 +196,8 @@ static inline void dccp_do_pmtu_discovery(struct sock *sk, | |||
196 | static void dccp_v4_err(struct sk_buff *skb, u32 info) | 196 | static void dccp_v4_err(struct sk_buff *skb, u32 info) |
197 | { | 197 | { |
198 | const struct iphdr *iph = (struct iphdr *)skb->data; | 198 | const struct iphdr *iph = (struct iphdr *)skb->data; |
199 | const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + | 199 | const u8 offset = iph->ihl << 2; |
200 | (iph->ihl << 2)); | 200 | const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + offset); |
201 | struct dccp_sock *dp; | 201 | struct dccp_sock *dp; |
202 | struct inet_sock *inet; | 202 | struct inet_sock *inet; |
203 | const int type = icmp_hdr(skb)->type; | 203 | const int type = icmp_hdr(skb)->type; |
@@ -207,7 +207,8 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info) | |||
207 | int err; | 207 | int err; |
208 | struct net *net = dev_net(skb->dev); | 208 | struct net *net = dev_net(skb->dev); |
209 | 209 | ||
210 | if (skb->len < (iph->ihl << 2) + 8) { | 210 | if (skb->len < offset + sizeof(*dh) || |
211 | skb->len < offset + __dccp_basic_hdr_len(dh)) { | ||
211 | ICMP_INC_STATS_BH(net, ICMP_MIB_INERRORS); | 212 | ICMP_INC_STATS_BH(net, ICMP_MIB_INERRORS); |
212 | return; | 213 | return; |
213 | } | 214 | } |