From: Frank Kardel Date: Sun, 19 Mar 2006 07:04:21 +0000 (+0000) Subject: ntp_restrict.c: X-Git-Tag: NTP_4_2_1P10_RC~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4a278ca358567cd52c6b2e34bd2eea611f932fe;p=thirdparty%2Fntp.git ntp_restrict.c: null deref: complete linked list handling beginng condition (Coverity CID 986 NetBSD Scan 5) bk: 441d0275o2A4GIpfDSexX22hpPkl1w --- diff --git a/ntpd/ntp_restrict.c b/ntpd/ntp_restrict.c index ede42257d..25047f916 100644 --- a/ntpd/ntp_restrict.c +++ b/ntpd/ntp_restrict.c @@ -527,8 +527,13 @@ hack_restrict( rl6->addr6 = addr6; rl6->mask6 = mask6; rl6->mflags = (u_short)mflags; - rl6->next = rlprev6->next; - rlprev6->next = rl6; + if (rlprev6) { + rl6->next = rlprev6->next; + rlprev6->next = rl6; + } else { + rl6->next = restrictlist6; + restrictlist6 = rl6; + } restrictcount6++; } if ((rl6->flags ^ (u_short)flags) & @@ -564,7 +569,11 @@ hack_restrict( if (rl6 != 0 && !IN6_IS_ADDR_UNSPECIFIED(&rl6->addr6) && !(rl6->mflags & RESM_INTERFACE)) { - rlprev6->next = rl6->next; + if (rlprev6) { + rlprev6->next = rl6->next; + } else { + restrictlist6 = rl6->next; + } restrictcount6--; if (rl6->flags & RES_LIMITED) { res_limited_refcnt6--;