]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2639] Check return value of ntp_adjtime()
authorHarlan Stenn <stenn@ntp.org>
Thu, 28 Aug 2014 07:13:56 +0000 (07:13 +0000)
committerHarlan Stenn <stenn@ntp.org>
Thu, 28 Aug 2014 07:13:56 +0000 (07:13 +0000)
bk: 53fed6b4GCXhO6Y-c9ioEmIpQrxPaQ

ChangeLog
ntpd/ntp_loopfilter.c

index 312154e8e1d811533a3df1440970053dac15122e..02ba53074fbd8f7ffa7cd3b6ae9b9cfff0dd7151 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* [Bug 2639] Check return value of ntp_adjtime().
 (4.2.7p466) 2014/08/27 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 2536] ntpd sandboxing support (libseccomp2) cleanup.
 (4.2.7p465) 2014/08/23 Released by Harlan Stenn <stenn@ntp.org>
index 560da0aab1b5d31056e93f8b3cb081d8b9157a10..caa54a0903d7e5bcbaaef8799e3ca1f5a7bc994f 100644 (file)
@@ -557,6 +557,8 @@ local_clock(
                 * Pass the stuff to the kernel. If it squeals, turn off
                 * the pps. In any case, fetch the kernel offset,
                 * frequency and jitter.
+                *
+                * XXX: HMS: What if ntp_adjtime() returns -1?
                 */
                if (ntp_adjtime(&ntv) == TIME_ERROR) {
                        if (pps_enable && !(ntv.status & STA_PPSSIGNAL))
@@ -589,10 +591,14 @@ local_clock(
                 * If the TAI changes, update the kernel TAI.
                 */
                if (loop_tai != sys_tai) {
-                       loop_tai = sys_tai;
+                       loop_tai = sys_tai; /* XXX: HMS: what if ntp_adjtime fails? */
                        ntv.modes = MOD_TAI;
                        ntv.constant = sys_tai;
-                       ntp_adjtime(&ntv);
+                       if (ntp_adjtime(&ntv) == -1) {
+                               msyslog(LOG_ERR,
+                                   "%s: ntp_adjtime(TAI) failed: %m",
+                                   __func__);
+                       }
                }
 #endif /* STA_NANO */
        }
@@ -826,7 +832,10 @@ set_freq(
                        loop_desc = "kernel";
                        ntv.freq = DTOFREQ(drift_comp);
                }
-               ntp_adjtime(&ntv);
+               if (ntp_adjtime(&ntv) == -1)
+                       msyslog(LOG_ERR,
+                           "%s: ntp_adjtime() failed: %m",
+                           __func__);
        }
 #endif /* KERNEL_PLL */
        mprintf_event(EVNT_FSET, NULL, "%s %.3f PPM", loop_desc,
@@ -859,8 +868,13 @@ start_kern_loop(void)
                msyslog(LOG_ERR, "sigaction() trap SIGSYS: %m");
                pll_control = FALSE;
        } else {
-               if (sigsetjmp(env, 1) == 0)
-                       ntp_adjtime(&ntv);
+               if (sigsetjmp(env, 1) == 0) {
+                       if (ntp_adjtime(&ntv) == -1) {
+                               msyslog(LOG_ERR,
+                                   "%s: ntp_adjtime() failed: %m",
+                                   __func__);
+                       }
+               }
                if (sigaction(SIGSYS, &sigsys, NULL)) {
                        msyslog(LOG_ERR,
                            "sigaction() restore SIGSYS: %m");
@@ -868,7 +882,11 @@ start_kern_loop(void)
                }
        }
 #else /* SIGSYS */
-       ntp_adjtime(&ntv);
+       if (ntp_adjtime(&ntv) == -1) {
+               msyslog(LOG_ERR,
+                   "%s: ntp_adjtime(TAI) failed: %m",
+                   __func__);
+       }
 #endif /* SIGSYS */
 
        /*