[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.4.2] Resolve a compiler warning from a 32-bit signed/unsigned comparison



commit 3e08dd9df1142b66e5f53a55d7e4c2803c3f9868
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Tue Jul 7 14:58:49 2020 -0400

    Resolve a compiler warning from a 32-bit signed/unsigned comparison
    
    This warning only affects platforms (like win32) with 32-bit time_t.
    
    Fixes bug 40028; bugfix on 0.3.2.8-rc.
---
 changes/bug40028   | 3 +++
 src/lib/tls/x509.c | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/changes/bug40028 b/changes/bug40028
new file mode 100644
index 000000000..cfd1ffe51
--- /dev/null
+++ b/changes/bug40028
@@ -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.
diff --git a/src/lib/tls/x509.c b/src/lib/tls/x509.c
index 67a8b49b9..b4a0f8dab 100644
--- a/src/lib/tls/x509.c
+++ b/src/lib/tls/x509.c
@@ -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



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits