aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2009-08-31 09:30:31 -0400
committerPatrick McHardy <kaber@trash.net>2009-08-31 09:30:31 -0400
commit488908696971c5ea1dcc5d13f29c158ba4f6ae7d (patch)
treee457b2e6bd0f6d91e894bf2936c8cca9e3b4ed3c /net/ipv6
parentee254fa44d902ab89fd0d66851701098f07872a7 (diff)
netfilter: ip6t_eui: fix read outside array bounds
Use memcmp() instead of open coded comparison that reads one byte past the intended end. Based on patch from Roel Kluin <roel.kluin@gmail.com> Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/netfilter/ip6t_eui64.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/net/ipv6/netfilter/ip6t_eui64.c b/net/ipv6/netfilter/ip6t_eui64.c
index db610bacbcce..ca287f6d2bce 100644
--- a/net/ipv6/netfilter/ip6t_eui64.c
+++ b/net/ipv6/netfilter/ip6t_eui64.c
@@ -23,7 +23,6 @@ static bool
23eui64_mt6(const struct sk_buff *skb, const struct xt_match_param *par) 23eui64_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
24{ 24{
25 unsigned char eui64[8]; 25 unsigned char eui64[8];
26 int i = 0;
27 26
28 if (!(skb_mac_header(skb) >= skb->head && 27 if (!(skb_mac_header(skb) >= skb->head &&
29 skb_mac_header(skb) + ETH_HLEN <= skb->data) && 28 skb_mac_header(skb) + ETH_HLEN <= skb->data) &&
@@ -42,12 +41,8 @@ eui64_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
42 eui64[4] = 0xfe; 41 eui64[4] = 0xfe;
43 eui64[0] ^= 0x02; 42 eui64[0] ^= 0x02;
44 43
45 i = 0; 44 if (!memcmp(ipv6_hdr(skb)->saddr.s6_addr + 8, eui64,
46 while (ipv6_hdr(skb)->saddr.s6_addr[8 + i] == eui64[i] 45 sizeof(eui64)))
47 && i < 8)
48 i++;
49
50 if (i == 8)
51 return true; 46 return true;
52 } 47 }
53 } 48 }