]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: acls using IPv6 subnets patterns incorrectly match IPs
authorCyril Bonté <cyril.bonte@free.fr>
Tue, 23 Oct 2012 19:28:31 +0000 (21:28 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 23 Oct 2012 23:00:53 +0000 (01:00 +0200)
Some tests revealed that IPs not in the range of IPv6 subnets incorrectly
matched (for example "acl BUG src 2804::/16" applied to a src IP "127.0.0.1").

This is caused by the acl_match_ip() function applies a mask in host byte
order, whereas it should be in network byte order.

src/acl.c

index d0ea731d282aeca1d16e2bc8e7b9ae52495cce8d..ef9630c89d125cb6fb3f1f72acb49b76740e5bba 100644 (file)
--- a/src/acl.c
+++ b/src/acl.c
@@ -776,7 +776,7 @@ int acl_match_ip(struct sample *smp, struct acl_pattern *pattern)
                for (pos = 0; bits > 0; pos += 4, bits -= 32) {
                        v4 = *(uint32_t*)&v6->s6_addr[pos] ^ *(uint32_t*)&pattern->val.ipv6.addr.s6_addr[pos];
                        if (bits < 32)
-                               v4 &= (~0U) << (32-bits);
+                               v4 &= htonl((~0U) << (32-bits));
                        if (v4)
                                return ACL_PAT_FAIL;
                }