]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: Fix use of 32-bit time_t in tcpreceiver.cc
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 21 Nov 2023 07:47:57 +0000 (08:47 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 21 Nov 2023 07:47:57 +0000 (08:47 +0100)
Reported by Coverity as 1524952

pdns/tcpreceiver.cc

index b22ef6f4d0450838a0b2e2061320f5f674f636e7..556df61e902606694ab87910449aabcd3978f8e9 100644 (file)
@@ -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<decltype(elapsed)>(remainingTotal)) {
         throw NetworkError("Timeout while reading data");
       }
       start = now;