[Bug 102] New: ipv6_prefix_length works only on LITTLE_ENDIAN and prefix_length % 8 == 0

bugzilla-daemon@netfilter.org bugzilla-daemon@netfilter.org
Sat, 21 Jun 2003 17:31:59 +0200


https://bugzilla.netfilter.org/cgi-bin/bugzilla/show_bug.cgi?id=102

           Summary: ipv6_prefix_length works only on LITTLE_ENDIAN and
                    prefix_length % 8 == 0
           Product: iptables userspace
           Version: 1.2.8
          Platform: other
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: libiptc
        AssignedTo: laforge@netfilter.org
        ReportedBy: mikko.markus.torni@iki.fi
                CC: netfilter-buglog@lists.netfilter.org


ipv6_prefix_length in libiptc/libip6tc.c works
only in these cases:
architecture is LITTLE_ENDIAN and given prefix is a multiple of 8
architecture is BIG_ENDIAN and given prefix is a multiple of 32

Here's one way to fix the problem:
--- iptables-1.2.8/libiptc/libip6tc.c   2002-02-14 01:13:23.000000000 +0200
+++ iptables-1.2.8-new/libiptc/libip6tc.c       2003-06-21 18:16:35.000000000 +0300
@@ -110,7 +110,7 @@
 #include "libiptc.c"
 
 #define BIT6(a, l) \
- (((a->in6_u.u6_addr32[(l) / 32]) >> ((l) & 31)) & 1)
+ ((ntohl(a->in6_u.u6_addr32[(l) / 32]) >> (31 - ((l) & 31))) & 1)
 
 int
 ipv6_prefix_length(const struct in6_addr *a)



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.