]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
ntp_restrict.c:
authorFrank Kardel <kardel@ntp.org>
Tue, 21 Mar 2006 10:43:26 +0000 (10:43 +0000)
committerFrank Kardel <kardel@ntp.org>
Tue, 21 Mar 2006 10:43:26 +0000 (10:43 +0000)
  null deref: fix another case of incomplete list handling (Coverity NetBSD Scan 8: CID 986)

bk: 441fd8ceVLVY424tyGxYaIRQx-3sPQ

ntpd/ntp_restrict.c

index 37812086821099db6956e4346d235aad775f1ff1..0f37c1614ec28301b946404fb31d16328173d18e 100644 (file)
@@ -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--;