Hi,

while reading over the IPv6addr code I notices that there is an overrun in
find_if() in the case where the prefix is 128. In this case,
mask.s6_addr[16] will be accessed twice, but that array only
has 16 elements.

The patch below takes the simple approach of just treating 128 as a corner
case and skiping the offending parts of the mask manipulation accordingly.
This should leave an mask cosisting of 0xff in each of the 16 elements
of mask.s6_addr, which is correct.

If there are no objections, I'll commit this change.

diff -r 57a79278cc1f resources/OCF/IPv6addr.c
--- a/resources/OCF/IPv6addr.c  Thu Apr 05 16:14:11 2007 +0200
+++ b/resources/OCF/IPv6addr.c  Thu Apr 05 16:36:22 2007 -0700
@@ -475,12 +475,14 @@ find_if(struct in6_addr* addr_target, in
                for (i = 0; i < 16; i++) {
                        mask.s6_addr[i] = 0;
                }       
-               n = plen / 8;
-               for (i = 0; i < n+1; i++) {
-                       mask.s6_addr[i] = 0xFF;
-               }
-               s = 8 - plen % 8;
-               mask.s6_addr[n]<<=s;
+               if (plen < 128) {
+                       n = plen / 8;
+                       for (i = 0; i < n+1; i++) {
+                               mask.s6_addr[i] = 0xFF;
+                       }
+                       s = 8 - plen % 8;
+                       mask.s6_addr[n]<<=s;
+               }
 
                /* compare addr and addr_target */
                same = TRUE;
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to