From: Paul Marks Date: Mon, 14 Jan 2013 01:39:10 +0000 (+0100) Subject: ntpd: fix incorrect m_status field in outgoing packets. Closes 5120 X-Git-Tag: 1_21_0~27 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b7841cf7b919b16d1bd4619154bf7cb4c22b4ccd;p=oweals%2Fbusybox.git ntpd: fix incorrect m_status field in outgoing packets. Closes 5120 When using busybox ntpd with an NTPv3 client and NTPv4 server (or vice versa), the version numbers can be incorrectly ORed together, yielding the bogus value of "NTPv7". This makes ntpd unusable with clients such as Chrony and Windows "Internet Time". This patch avoids the version mangling, by copying only the Leap Indicator bits from the server's status field. Signed-off-by: Paul Marks Signed-off-by: Denys Vlasenko --- diff --git a/networking/ntpd.c b/networking/ntpd.c index 45485c080..79b7c3793 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c @@ -1851,7 +1851,7 @@ recv_and_process_client_pkt(void /*int fd*/) /* Build a reply packet */ memset(&msg, 0, sizeof(msg)); - msg.m_status = G.stratum < MAXSTRAT ? G.ntp_status : LI_ALARM; + msg.m_status = G.stratum < MAXSTRAT ? (G.ntp_status & LI_MASK) : LI_ALARM; msg.m_status |= (query_status & VERSION_MASK); msg.m_status |= ((query_status & MODE_MASK) == MODE_CLIENT) ? MODE_SERVER : MODE_SYM_PAS;