]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Resolve a compiler warning from a 32-bit signed/unsigned comparison
authorNick Mathewson <nickm@torproject.org>
Tue, 7 Jul 2020 18:58:49 +0000 (14:58 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 7 Jul 2020 19:05:38 +0000 (15:05 -0400)
This warning only affects platforms (like win32) with 32-bit time_t.

Fixes bug 40028; bugfix on 0.3.2.8-rc.

changes/bug40028 [new file with mode: 0644]
src/lib/tls/x509.c

diff --git a/changes/bug40028 b/changes/bug40028
new file mode 100644 (file)
index 0000000..cfd1ffe
--- /dev/null
@@ -0,0 +1,3 @@
+  o Minor bugfixes (compiler warnings):
+    - Fix a compiler warning on platforms with 32-bit time_t values.
+      Fixes bug 40028; bugfix on 0.3.2.8-rc.
index 67a8b49b9d440dfce2b0966d377c1296e4f2d172..b4a0f8dabf2d53e52d808a1667ba81d175efe3de 100644 (file)
@@ -23,6 +23,7 @@ tor_tls_pick_certificate_lifetime(time_t now,
                                   time_t *start_time_out,
                                   time_t *end_time_out)
 {
+  tor_assert(cert_lifetime < INT_MAX);
   time_t start_time, end_time;
   /* Make sure we're part-way through the certificate lifetime, rather
    * than having it start right now. Don't choose quite uniformly, since
@@ -36,7 +37,7 @@ tor_tls_pick_certificate_lifetime(time_t now,
   const time_t start_granularity = 24*3600;
   time_t earliest_start_time;
   /* Don't actually start in the future! */
-  if (cert_lifetime <= min_real_lifetime + start_granularity) {
+  if ((int)cert_lifetime <= min_real_lifetime + start_granularity) {
     earliest_start_time = now - 1;
   } else {
     earliest_start_time = now + min_real_lifetime + start_granularity