diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-10-18 00:30:34 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-10-18 00:30:34 -0400 |
commit | 440725000cba0b1a68ca2df20124be3a5b7f7702 (patch) | |
tree | ae278e1b2b5aaed8f1e9d55e91c2913cde5ac653 /net/xfrm/xfrm_input.c | |
parent | 7aa68cb90638ccc36559a936814e4c089892b3d9 (diff) |
[IPSEC]: Fix length check in xfrm_parse_spi
Currently xfrm_parse_spi requires there to be 16 bytes for AH and ESP.
In contrived cases there may not actually be 16 bytes there since the
respective header sizes are less than that (8 and 12 currently).
This patch changes the test to use the actual header length instead of 16.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm/xfrm_input.c')
-rw-r--r-- | net/xfrm/xfrm_input.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c index 113f44429982..cb97fda1b6df 100644 --- a/net/xfrm/xfrm_input.c +++ b/net/xfrm/xfrm_input.c | |||
@@ -49,13 +49,16 @@ EXPORT_SYMBOL(secpath_dup); | |||
49 | int xfrm_parse_spi(struct sk_buff *skb, u8 nexthdr, __be32 *spi, __be32 *seq) | 49 | int xfrm_parse_spi(struct sk_buff *skb, u8 nexthdr, __be32 *spi, __be32 *seq) |
50 | { | 50 | { |
51 | int offset, offset_seq; | 51 | int offset, offset_seq; |
52 | int hlen; | ||
52 | 53 | ||
53 | switch (nexthdr) { | 54 | switch (nexthdr) { |
54 | case IPPROTO_AH: | 55 | case IPPROTO_AH: |
56 | hlen = sizeof(struct ip_auth_hdr); | ||
55 | offset = offsetof(struct ip_auth_hdr, spi); | 57 | offset = offsetof(struct ip_auth_hdr, spi); |
56 | offset_seq = offsetof(struct ip_auth_hdr, seq_no); | 58 | offset_seq = offsetof(struct ip_auth_hdr, seq_no); |
57 | break; | 59 | break; |
58 | case IPPROTO_ESP: | 60 | case IPPROTO_ESP: |
61 | hlen = sizeof(struct ip_esp_hdr); | ||
59 | offset = offsetof(struct ip_esp_hdr, spi); | 62 | offset = offsetof(struct ip_esp_hdr, spi); |
60 | offset_seq = offsetof(struct ip_esp_hdr, seq_no); | 63 | offset_seq = offsetof(struct ip_esp_hdr, seq_no); |
61 | break; | 64 | break; |
@@ -69,7 +72,7 @@ int xfrm_parse_spi(struct sk_buff *skb, u8 nexthdr, __be32 *spi, __be32 *seq) | |||
69 | return 1; | 72 | return 1; |
70 | } | 73 | } |
71 | 74 | ||
72 | if (!pskb_may_pull(skb, 16)) | 75 | if (!pskb_may_pull(skb, hlen)) |
73 | return -EINVAL; | 76 | return -EINVAL; |
74 | 77 | ||
75 | *spi = *(__be32*)(skb_transport_header(skb) + offset); | 78 | *spi = *(__be32*)(skb_transport_header(skb) + offset); |