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

[tor-commits] [tor/maint-0.2.2] Fix a potential null deref when rebuilding md cache



commit 1827e60976d54d1917dfc54bdf62b4818662ac12
Author: Sebastian Hahn <sebastian@xxxxxxxxxxxxxx>
Date:   Tue Apr 26 04:23:35 2011 +0200

    Fix a potential null deref when rebuilding md cache
    
    Issue discovered using clang's static analyzer
---
 changes/mdesc_null_deref |    5 +++++
 src/or/microdesc.c       |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/changes/mdesc_null_deref b/changes/mdesc_null_deref
new file mode 100644
index 0000000..30f0280
--- /dev/null
+++ b/changes/mdesc_null_deref
@@ -0,0 +1,5 @@
+  o Minor bugfixes:
+    - Avoid a possible null-pointer dereference when rebuilding the mdesc
+      cache without actually having any descriptors to cache. Bugfix on
+      0.2.2.6-alpha. Issue discovered using clang's static analyzer.
+
diff --git a/src/or/microdesc.c b/src/or/microdesc.c
index 73d2285..5740c40 100644
--- a/src/or/microdesc.c
+++ b/src/or/microdesc.c
@@ -423,7 +423,7 @@ microdesc_cache_rebuild(microdesc_cache_t *cache, int force)
   cache->journal_len = 0;
   cache->bytes_dropped = 0;
 
-  new_size = (int)cache->cache_content->size;
+  new_size = cache->cache_content ? (int)cache->cache_content->size : 0;
   log_info(LD_DIR, "Done rebuilding microdesc cache. "
            "Saved %d bytes; %d still used.",
            orig_size-new_size, new_size);



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