aboutsummaryrefslogtreecommitdiff
path: root/networking/ntpd.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-09-29 14:19:17 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2020-09-29 14:19:17 +0200
commitafb5d8b2db432b8433ba80a1206ae41ef4f4ea8b (patch)
tree279a6c1f5b1cf4da9a85fb968030d467e2f87be0 /networking/ntpd.c
parenta949399d178f7b052ada2099c62621736eafce44 (diff)
downloadbusybox-afb5d8b2db432b8433ba80a1206ae41ef4f4ea8b.tar.gz
ntpd: fix the case where two replies received at once and first one causes a step
function old new delta recv_and_process_peer_pkt 2476 2486 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/ntpd.c')
-rw-r--r--networking/ntpd.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c
index d721fe80c..44e711232 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -2025,6 +2025,15 @@ recv_and_process_peer_pkt(peer_t *p)
offset = 0;
+ /* The below can happen as follows:
+ * = we receive two peer rsponses at once.
+ * = recv_and_process_peer_pkt(PEER1) -> update_local_clock()
+ * -> step_time() and it closes all other fds, sets all ->fd to -1.
+ * = recv_and_process_peer_pkt(PEER2) sees PEER2->fd == -1
+ */
+ if (p->p_fd < 0)
+ return;
+
/* We can recvfrom here and check from.IP, but some multihomed
* ntp servers reply from their *other IP*.
* TODO: maybe we should check at least what we can: from.port == 123?