[PATCH] Fix the "NTPv7" version mangling in ntpd.

Paul Marks paul at pmarks.net
Mon Jan 7 00:02:30 UTC 2013


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.

Bug: https://bugs.busybox.net/show_bug.cgi?id=5120

Signed-off-by: Paul Marks <paul at pmarks.net>
---
 networking/ntpd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/networking/ntpd.c b/networking/ntpd.c
index 7facf94..00e709d 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;
-- 
1.8.0.2



More information about the busybox mailing list