]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Sec 3119] Trap crash
authorJuergen Perlinger <perlinger@ntp.org>
Fri, 23 Sep 2016 18:00:55 +0000 (20:00 +0200)
committerJuergen Perlinger <perlinger@ntp.org>
Fri, 23 Sep 2016 18:00:55 +0000 (20:00 +0200)
bk: 57e56dd78oiRnU9VrH-kn67zwJOoaA

ChangeLog
ntpd/ntp_control.c

index 0805467dc6b9b1ce7768a039f6a2d87af37546b9..9a5c7c6ea6036856945c12c9863d85951f045ca5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+---
+* [Sec 3119] Trap crash <perlinger@ntp.org>
+
 ---
 (4.2.8p8) 2016/06/02 Released by Harlan Stenn <stenn@ntp.org>
 
index 07b5697f1536605efed3f4ee726d21ee94a59a70..77defbd753b77b2b009e6eb07062ae72df81791c 100644 (file)
@@ -4997,6 +4997,22 @@ report_event(
        if (num_ctl_traps <= 0)
                return;
 
+       /* [Bug 3119]
+        * Peer Events should be associated with a peer -- hence the
+        * name. But there are instances where this function is called
+        * *without* a valid peer. This happens e.g. with an unsolicited
+        * CryptoNAK, or when a leap second alarm is going off while
+        * currently without a system peer.
+        *
+        * The most sensible approach to this seems to bail out here if
+        * this happens. Avoiding to call this function would also
+        * bypass the log reporting in the first part of this function,
+        * and this is probably not the best of all options.
+        *   -*-perlinger@ntp.org-*-
+        */
+       if ((err & PEER_EVENT) && !peer)
+               return;
+
        /*
         * Set up the outgoing packet variables
         */
@@ -5013,15 +5029,14 @@ report_event(
                /* Include the core system variables and the list. */
                for (i = 1; i <= CS_VARLIST; i++)
                        ctl_putsys(i);
-       } else {
-               INSIST(peer != NULL);
+       } else if (NULL != peer) { /* paranoia -- skip output */
                rpkt.associd = htons(peer->associd);
                rpkt.status = htons(ctlpeerstatus(peer));
 
                /* Dump it all. Later, maybe less. */
                for (i = 1; i <= CP_MAX_NOAUTOKEY; i++)
                        ctl_putpeer(i, peer);
-#ifdef REFCLOCK
+#          ifdef REFCLOCK
                /*
                 * for clock exception events: add clock variables to
                 * reflect info on exception
@@ -5047,7 +5062,7 @@ report_event(
                                                    FALSE);
                        free_varlist(cs.kv_list);
                }
-#endif /* REFCLOCK */
+#          endif /* REFCLOCK */
        }
 
        /*