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

[tor-commits] [tor/master] Fix a bug in microdescs_add_to_cache when listed_at == -1



commit 012068935a632fa3d578cee956b6aed141055379
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Mon Mar 11 16:20:20 2013 -0400

    Fix a bug in microdescs_add_to_cache when listed_at == -1
    
    This bug affects hosts where time_t is unsigned, which AFAICT does
    not include anything we currently support.  (It _does_ include
    OpenVMS, about a month of BSD4.2's history[1], and a lot of the 1970s.)
    
    There are probably more bugs when time_t is unsigned.  This one was
    
    [1] http://mail-index.netbsd.org/tech-userlevel/1998/06/04/0000.html
---
 changes/warn-unsigned-time_t |    6 ++++++
 src/or/microdesc.c           |    4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/changes/warn-unsigned-time_t b/changes/warn-unsigned-time_t
index 5f0c36d..f57f85a 100644
--- a/changes/warn-unsigned-time_t
+++ b/changes/warn-unsigned-time_t
@@ -1,3 +1,9 @@
+  o Minor bugfixes (portability):
+    - On the chance that somebody manages to build Tor on a
+      platform where time_t is unsigned, correct the way that
+      microdesc_add_to_cache handles negative time arguments. Fix for
+      bug 8042; bugfix on 0.2.3.1-alpha.
+
   o Build improvements:
     - Warn if building on a platform with an unsigned time_t: there
       are too many places where Tor currently assumes that time_t can
diff --git a/src/or/microdesc.c b/src/or/microdesc.c
index ac48930..a1c0e3d 100644
--- a/src/or/microdesc.c
+++ b/src/or/microdesc.c
@@ -135,7 +135,7 @@ get_microdesc_cache(void)
  * ending at <b>eos</b>, and store them in <b>cache</b>.  If <b>no_save</b>,
  * mark them as non-writable to disk.  If <b>where</b> is SAVED_IN_CACHE,
  * leave their bodies as pointers to the mmap'd cache.  If where is
- * <b>SAVED_NOWHERE</b>, do not allow annotations.  If listed_at is positive,
+ * <b>SAVED_NOWHERE</b>, do not allow annotations.  If listed_at is not -1,
  * set the last_listed field of every microdesc to listed_at.  If
  * requested_digests is non-null, then it contains a list of digests we mean
  * to allow, so we should reject any non-requested microdesc with a different
@@ -155,7 +155,7 @@ microdescs_add_to_cache(microdesc_cache_t *cache,
   descriptors = microdescs_parse_from_string(s, eos,
                                              allow_annotations,
                                              copy_body);
-  if (listed_at > 0) {
+  if (listed_at != (time_t)-1) {
     SMARTLIST_FOREACH(descriptors, microdesc_t *, md,
                       md->last_listed = listed_at);
   }



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