]> git.proxmox.com Git - mirror_frr.git/commitdiff
ospf6d: fix out of bounds write in ospf6_prefix_apply_mask
authorDavid Lamparter <equinox@diac24.net>
Mon, 31 May 2010 10:02:31 +0000 (12:02 +0200)
committerDavid Lamparter <equinox@diac24.net>
Sat, 11 Feb 2012 14:26:19 +0000 (15:26 +0100)
ospf6_prefix_apply_mask would write one byte beyond the 4/8/12
bytes allocated for prefixes of length 32/64/96.

based on report and patch by Jon Andersson <jon.andersson@thales.no>

Reported-by: Jon Andersson <jon.andersson@thales.no>
Signed-off-by: David Lamparter <equinox@diac24.net>
ospf6d/ospf6_proto.c

index c792aa4526136b8e79d5460cae5d785159a18465..d011601f07af70f95a86447796e604e173d5787d 100644 (file)
@@ -42,11 +42,10 @@ ospf6_prefix_apply_mask (struct ospf6_prefix *op)
       return;
     }
 
-  if (index == 16)
-    return;
-
-  pnt[index] &= mask;
-  index ++;
+  /* nonzero mask means no check for this byte because if it contains
+   * prefix bits it must be there for us to write */
+  if (mask)
+    pnt[index++] &= mask;
 
   while (index < OSPF6_PREFIX_SPACE (op->prefix_length))
     pnt[index++] = 0;