null deref: complete linked list handling beginng condition (Coverity CID 986)

This commit is contained in:
kardel 2006-03-19 07:02:47 +00:00
parent 0c47a67596
commit 24781071d1
1 changed files with 13 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ntp_restrict.c,v 1.2 2003/12/04 16:23:37 drochner Exp $ */ /* $NetBSD: ntp_restrict.c,v 1.3 2006/03/19 07:02:47 kardel Exp $ */
/* /*
* ntp_restrict.c - determine host restrictions * ntp_restrict.c - determine host restrictions
@ -529,8 +529,13 @@ hack_restrict(
rl6->addr6 = addr6; rl6->addr6 = addr6;
rl6->mask6 = mask6; rl6->mask6 = mask6;
rl6->mflags = (u_short)mflags; rl6->mflags = (u_short)mflags;
rl6->next = rlprev6->next; if (rlprev6) {
rlprev6->next = rl6; rl6->next = rlprev6->next;
rlprev6->next = rl6;
} else {
rl6->next = restrictlist6;
restrictlist6 = rl6;
}
restrictcount6++; restrictcount6++;
} }
if ((rl6->flags ^ (u_short)flags) & if ((rl6->flags ^ (u_short)flags) &
@ -566,7 +571,11 @@ hack_restrict(
if (rl6 != 0 && if (rl6 != 0 &&
!IN6_IS_ADDR_UNSPECIFIED(&rl6->addr6) !IN6_IS_ADDR_UNSPECIFIED(&rl6->addr6)
&& !(rl6->mflags & RESM_INTERFACE)) { && !(rl6->mflags & RESM_INTERFACE)) {
rlprev6->next = rl6->next; if (rlprev6) {
rlprev6->next = rl6->next;
} else {
restrictlist6 = rl6->next;
}
restrictcount6--; restrictcount6--;
if (rl6->flags & RES_LIMITED) { if (rl6->flags & RES_LIMITED) {
res_limited_refcnt6--; res_limited_refcnt6--;