From 4b5f4650260245bc8f489fa861dc6a2f7a8baa0c Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Fri, 17 Jan 2014 17:37:07 +0100 Subject: [PATCH] Don't allow maxpoll to be set shorter than minpoll --- ntp_core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ntp_core.c b/ntp_core.c index f2f67af..58e8aae 100644 --- a/ntp_core.c +++ b/ntp_core.c @@ -289,6 +289,8 @@ NCR_GetInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type, SourcePar result->minpoll = params->minpoll; result->maxpoll = params->maxpoll; + if (result->maxpoll < result->minpoll) + result->maxpoll = result->minpoll; result->min_stratum = params->min_stratum; result->presend_minpoll = params->presend_minpoll; @@ -1606,6 +1608,8 @@ NCR_ModifyMinpoll(NCR_Instance inst, int new_minpoll) { inst->minpoll = new_minpoll; LOG(LOGS_INFO, LOGF_NtpCore, "Source %s new minpoll %d", UTI_IPToString(&inst->remote_addr.ip_addr), new_minpoll); + if (inst->maxpoll < inst->minpoll) + NCR_ModifyMaxpoll(inst, inst->minpoll); } /* ================================================== */ @@ -1615,6 +1619,8 @@ NCR_ModifyMaxpoll(NCR_Instance inst, int new_maxpoll) { inst->maxpoll = new_maxpoll; LOG(LOGS_INFO, LOGF_NtpCore, "Source %s new maxpoll %d", UTI_IPToString(&inst->remote_addr.ip_addr), new_maxpoll); + if (inst->minpoll > inst->maxpoll) + NCR_ModifyMinpoll(inst, inst->maxpoll); } /* ================================================== */