avoid out-of-bound memory access if len == 128.

from Ted Unangst via Colin Percival
This commit is contained in:
itojun 2004-02-23 05:01:04 +00:00
parent 985db8fe7c
commit aaa4bd9a6c
1 changed files with 4 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6.c,v 1.84 2003/12/10 11:46:33 itojun Exp $ */ /* $NetBSD: in6.c,v 1.85 2004/02/23 05:01:04 itojun Exp $ */
/* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */ /* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */
/* /*
@ -62,7 +62,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.84 2003/12/10 11:46:33 itojun Exp $"); __KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.85 2004/02/23 05:01:04 itojun Exp $");
#include "opt_inet.h" #include "opt_inet.h"
@ -2238,7 +2238,8 @@ in6_are_prefix_equal(p1, p2, len)
if (bcmp(&p1->s6_addr, &p2->s6_addr, bytelen)) if (bcmp(&p1->s6_addr, &p2->s6_addr, bytelen))
return (0); return (0);
if (p1->s6_addr[bytelen] >> (8 - bitlen) != if (bitlen != 0 &&
p1->s6_addr[bytelen] >> (8 - bitlen) !=
p2->s6_addr[bytelen] >> (8 - bitlen)) p2->s6_addr[bytelen] >> (8 - bitlen))
return (0); return (0);