From: Remi Gacogne Date: Tue, 21 Nov 2023 07:47:57 +0000 (+0100) Subject: auth: Fix use of 32-bit time_t in tcpreceiver.cc X-Git-Tag: rec-5.0.0-rc1~3^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=600c8a6522305c7b14ed819e0bd99a1d54c24aea;p=thirdparty%2Fpdns.git auth: Fix use of 32-bit time_t in tcpreceiver.cc Reported by Coverity as 1524952 --- diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index b22ef6f4d0..556df61e90 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -131,8 +131,8 @@ static int readnWithTimeout(int fd, void* buffer, unsigned int n, unsigned int i bytes -= ret; if (totalTimeout) { time_t now = time(nullptr); - unsigned int elapsed = now - start; - if (elapsed >= remainingTotal) { + const auto elapsed = now - start; + if (elapsed > 0 && elapsed >= static_cast(remainingTotal)) { throw NetworkError("Timeout while reading data"); } start = now;