]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Proper NULL checking for hsdesc publication
authorSebastian Hahn <sebastian@torproject.org>
Tue, 23 Feb 2010 16:09:02 +0000 (17:09 +0100)
committerSebastian Hahn <sebastian@torproject.org>
Fri, 26 Feb 2010 04:49:34 +0000 (05:49 +0100)
Fix a dereference-then-NULL-check sequence. This bug wasn't triggered
in the wild, but we should fix it anyways in case it ever happens.
Also make sure users get a note about this being a bug when they
see it in their log.

Thanks to ekir for discovering and reporting this bug.

ChangeLog
src/or/rendcommon.c

index 24b0cc6d1a0ceab75ad94296b6fc611353bd6b4e..525a00b37846fcb623022d38b75ec1892c8312f4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@ Changes in version 0.2.1.25 - 2010-??-??
     - When freeing a cipher, zero it out completely. We only zeroed
       the first ptrsize bytes. Bugfix on tor-0.0.2pre8. Discovered
       and patched by ekir. Fixes bug 1254.
+  o Minor bugfixes:
+    - Fix a dereference-then-NULL-check sequence when publishing
+      descriptors. Bugfix on tor-0.2.1.5-alpha. Discovered by ekir,
+      fixes bug 1255.
 
 Changes in version 0.2.1.24 - 2010-02-21
   Tor 0.2.1.24 makes Tor work again on the latest OS X -- this time
index d21eb42efede20f84160fa2e5e9f7053235041a7..a625900cdfa3b300d8c0cfd19c514b0598316dd0 100644 (file)
@@ -451,17 +451,17 @@ rend_encode_v2_descriptors(smartlist_t *descs_out,
   size_t ipos_len = 0, ipos_encrypted_len = 0;
   int k;
   uint32_t seconds_valid;
-  crypto_pk_env_t *service_key = auth_type == REND_STEALTH_AUTH ?
-                                 client_key : desc->pk;
+  crypto_pk_env_t *service_key;
+  if (!desc) {
+    log_warn(LD_BUG, "Could not encode v2 descriptor: No desc given.");
+    return -1;
+  }
+  service_key = (auth_type == REND_STEALTH_AUTH) ? client_key : desc->pk;
   tor_assert(service_key);
   if (auth_type == REND_STEALTH_AUTH) {
     descriptor_cookie = smartlist_get(client_cookies, 0);
     tor_assert(descriptor_cookie);
   }
-  if (!desc) {
-    log_warn(LD_REND, "Could not encode v2 descriptor: No desc given.");
-    return -1;
-  }
   /* Obtain service_id from public key. */
   crypto_pk_get_digest(service_key, service_id);
   /* Calculate current time-period. */