From: Frank Kardel Date: Tue, 21 Mar 2006 10:43:26 +0000 (+0000) Subject: ntp_restrict.c: X-Git-Tag: NTP_4_2_1P10_RC~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0fccad234d6decbfd4fccc9f4bb0cc3073da2438;p=thirdparty%2Fntp.git ntp_restrict.c: null deref: fix another case of incomplete list handling (Coverity NetBSD Scan 8: CID 986) bk: 441fd8ceVLVY424tyGxYaIRQx-3sPQ --- diff --git a/ntpd/ntp_restrict.c b/ntpd/ntp_restrict.c index 378120868..0f37c1614 100644 --- a/ntpd/ntp_restrict.c +++ b/ntpd/ntp_restrict.c @@ -440,8 +440,13 @@ hack_restrict( rl->mask = mask; rl->mflags = (u_short)mflags; - rl->next = rlprev->next; - rlprev->next = rl; + if (rlprev == NULL) { + rl->next = restrictlist; + restrictlist = rl; + } else { + rl->next = rlprev->next; + rlprev->next = rl; + } restrictcount++; } if ((rl->flags ^ (u_short)flags) & @@ -477,7 +482,11 @@ hack_restrict( if (rl != 0 && rl->addr != htonl(INADDR_ANY) && !(rl->mflags & RESM_INTERFACE)) { - rlprev->next = rl->next; + if (rlprev != NULL) { + rlprev->next = rl->next; + } else { + restrictlist = rl->next; + } restrictcount--; if (rl->flags & RES_LIMITED) { res_limited_refcnt--;