Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP4
chrony.19115
chrony-select-timeout.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File chrony-select-timeout.patch of Package chrony.19115
From d0b24860363a3704e28569ce9a6987717834edea Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar <mlichvar@redhat.com> Date: Tue, 5 Dec 2017 11:08:24 +0100 Subject: [PATCH] client: don't call select() with invalid timeout If the system clock was stepped forward after chronyc sent a request and before it read the clock in order to calculate the receive timeout, select() could be called with a negative timeout, which resulted in an infinite loop waiting for select() to succeed. Fix the submit_request() function to not call select() with a negative timeout. Also, return immediately on any error of select(). --- client.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client.c b/client.c index 5c3a99e..4e23158 100644 --- a/client.c +++ b/client.c @@ -1394,9 +1394,16 @@ submit_request(CMD_Request *request, CMD_Reply *reply) timeout = initial_timeout / 1000.0 * (1U << (n_attempts - 1)) - UTI_DiffTimespecsToDouble(&ts_now, &ts_start); - UTI_DoubleToTimeval(timeout, &tv); DEBUG_LOG("Timeout %f seconds", timeout); + /* Avoid calling select() with an invalid timeout */ + if (timeout <= 0.0) { + new_attempt = 1; + continue; + } + + UTI_DoubleToTimeval(timeout, &tv); + FD_ZERO(&rdfd); FD_ZERO(&wrfd); FD_ZERO(&exfd); @@ -1410,6 +1417,7 @@ submit_request(CMD_Request *request, CMD_Reply *reply) if (select_status < 0) { DEBUG_LOG("select failed : %s", strerror(errno)); + return 0; } else if (select_status == 0) { /* Timeout must have elapsed, try a resend? */ new_attempt = 1; -- 2.16.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor