diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-03-27 18:24:59 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-03-27 18:24:59 -0400 |
commit | 0b795ce6de339ccdabe17cb78f632df6f74901e2 (patch) | |
tree | 59e9ae5e44d0dd8632d0af03a2bd5051b1112bbe | |
parent | 5e7d505850607a16f6051a19ff60c39ff4c8393e (diff) | |
parent | 0c13a84c0d9282e597227d117e23216bb459caad (diff) | |
download | tor-0b795ce6de339ccdabe17cb78f632df6f74901e2.tar.gz tor-0b795ce6de339ccdabe17cb78f632df6f74901e2.zip |
Merge remote-tracking branch 'catalyst-github/bug25629-032' into maint-0.3.2
-rw-r--r-- | changes/bug25629 | 3 | ||||
-rw-r--r-- | src/or/nodelist.c | 28 |
2 files changed, 17 insertions, 14 deletions
diff --git a/changes/bug25629 b/changes/bug25629 new file mode 100644 index 0000000000..190928a941 --- /dev/null +++ b/changes/bug25629 @@ -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. diff --git a/src/or/nodelist.c b/src/or/nodelist.c index 9a477ecf43..ac94498558 100644 --- a/src/or/nodelist.c +++ b/src/or/nodelist.c @@ -525,22 +525,22 @@ nodelist_add_microdesc(microdesc_t *md) if (rs == NULL) return NULL; node = node_get_mutable_by_id(rs->identity_digest); - if (node) { - node_remove_from_ed25519_map(node); - if (node->md) - node->md->held_by_nodes--; + if (node == NULL) + return NULL; - node->md = md; - md->held_by_nodes++; - /* Setting the HSDir index requires the ed25519 identity key which can - * only be found either in the ri or md. This is why this is called here. - * Only nodes supporting HSDir=2 protocol version needs this index. */ - if (rs->supports_v3_hsdir) { - node_set_hsdir_index(node, ns); - } - node_add_to_ed25519_map(node); - } + node_remove_from_ed25519_map(node); + if (node->md) + node->md->held_by_nodes--; + node->md = md; + md->held_by_nodes++; + /* Setting the HSDir index requires the ed25519 identity key which can + * only be found either in the ri or md. This is why this is called here. + * Only nodes supporting HSDir=2 protocol version needs this index. */ + if (rs->supports_v3_hsdir) { + node_set_hsdir_index(node, ns); + } + node_add_to_ed25519_map(node); node_add_to_address_set(node); return node; |