From: Harlan Stenn Date: Thu, 28 Aug 2014 07:13:56 +0000 (+0000) Subject: [Bug 2639] Check return value of ntp_adjtime() X-Git-Tag: NTP_4_2_7P467~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2894b1fda95654c335f6d14d4c4f6ba8cf9b896;p=thirdparty%2Fntp.git [Bug 2639] Check return value of ntp_adjtime() bk: 53fed6b4GCXhO6Y-c9ioEmIpQrxPaQ --- diff --git a/ChangeLog b/ChangeLog index 312154e8e..02ba53074 100644 --- 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 * [Bug 2536] ntpd sandboxing support (libseccomp2) cleanup. (4.2.7p465) 2014/08/23 Released by Harlan Stenn diff --git a/ntpd/ntp_loopfilter.c b/ntpd/ntp_loopfilter.c index 560da0aab..caa54a090 100644 --- a/ntpd/ntp_loopfilter.c +++ b/ntpd/ntp_loopfilter.c @@ -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 */ /*