1 From b7841cf7b919b16d1bd4619154bf7cb4c22b4ccd Mon Sep 17 00:00:00 2001
2 From: Paul Marks <paul@pmarks.net>
3 Date: Mon, 14 Jan 2013 01:39:10 +0000
4 Subject: ntpd: fix incorrect m_status field in outgoing packets. Closes 5120
6 When using busybox ntpd with an NTPv3 client and NTPv4 server (or vice
7 versa), the version numbers can be incorrectly ORed together, yielding
8 the bogus value of "NTPv7". This makes ntpd unusable with clients
9 such as Chrony and Windows "Internet Time".
11 This patch avoids the version mangling, by copying only the Leap
12 Indicator bits from the server's status field.
14 Signed-off-by: Paul Marks <paul@pmarks.net>
15 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
17 (limited to 'networking/ntpd.c')
19 --- a/networking/ntpd.c
20 +++ b/networking/ntpd.c
21 @@ -1794,7 +1794,7 @@ recv_and_process_client_pkt(void /*int f
23 /* Build a reply packet */
24 memset(&msg, 0, sizeof(msg));
25 - msg.m_status = G.stratum < MAXSTRAT ? G.ntp_status : LI_ALARM;
26 + msg.m_status = G.stratum < MAXSTRAT ? (G.ntp_status & LI_MASK) : LI_ALARM;
27 msg.m_status |= (query_status & VERSION_MASK);
28 msg.m_status |= ((query_status & MODE_MASK) == MODE_CLIENT) ?
29 MODE_SERVER : MODE_SYM_PAS;