]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix CID 1430932
authorTaylor Yu <catalyst@torproject.org>
Mon, 26 Mar 2018 22:51:50 +0000 (17:51 -0500)
committerTaylor Yu <catalyst@torproject.org>
Tue, 27 Mar 2018 20:29:00 +0000 (15:29 -0500)
Coverity found a null pointer reference in nodelist_add_microdesc().
This is almost certainly impossible assuming that the routerstatus_t
returned by router_get_consensus_status_by_descriptor_digest() always
corresponds to an entry in the nodelist.  Fixes bug 25629.

changes/bug25629 [new file with mode: 0644]
src/or/nodelist.c

diff --git a/changes/bug25629 b/changes/bug25629
new file mode 100644 (file)
index 0000000..190928a
--- /dev/null
@@ -0,0 +1,3 @@
+  o Minor bugfixes (C correctness):
+    - Fix a very unlikely null pointer dereference.  Fixes bug 25629;
+      bugfix on 0.2.9.15.  Found by Coverity; this is CID 1430932.
index 5a02648c5cc6486a56f0a20c64ab8c528f877f93..26f990b08cd096ef7541355faaa532ec1f2c17b5 100644 (file)
@@ -263,13 +263,12 @@ nodelist_add_microdesc(microdesc_t *md)
   if (rs == NULL)
     return NULL;
   node = node_get_mutable_by_id(rs->identity_digest);
-  if (node) {
-    if (node->md)
-      node->md->held_by_nodes--;
-    node->md = md;
-    md->held_by_nodes++;
-  }
-
+  if (node == NULL)
+    return NULL;
+  if (node->md)
+    node->md->held_by_nodes--;
+  node->md = md;
+  md->held_by_nodes++;
   node_add_to_address_set(node);
 
   return node;