Merge remote-tracking branch 'teor/Bug-23966'

This commit is contained in:
Nick Mathewson 2018-01-10 09:38:38 -05:00
commit 4715d81809
2 changed files with 10 additions and 11 deletions

5
changes/ticket23966 Normal file
View File

@ -0,0 +1,5 @@
o Code simplification and refactoring:
- Remove duplicate code in node_has_curve25519_onion_key() and
node_get_curve25519_onion_key(), and add a check for a zero microdesc
curve25519 onion key. Closes ticket 23966, patch by "aruna1234" and
"teor".

View File

@ -1637,24 +1637,18 @@ microdesc_has_curve25519_onion_key(const microdesc_t *md)
int int
node_has_curve25519_onion_key(const node_t *node) node_has_curve25519_onion_key(const node_t *node)
{ {
if (!node) return(node_get_curve25519_onion_key(node)!=NULL);
return 0;
if (node->ri)
return routerinfo_has_curve25519_onion_key(node->ri);
else if (node->md)
return microdesc_has_curve25519_onion_key(node->md);
else
return 0;
} }
/** Return the curve25519 key of <b>node</b>, or NULL if none. */ /** Return the curve25519 key of <b>node</b>, or NULL if none. */
const curve25519_public_key_t * const curve25519_public_key_t *
node_get_curve25519_onion_key(const node_t *node) node_get_curve25519_onion_key(const node_t *node)
{ {
if (node->ri) if (!node)
return NULL;
if (routerinfo_has_curve25519_onion_key(node->ri))
return node->ri->onion_curve25519_pkey; return node->ri->onion_curve25519_pkey;
else if (node->md) else if (microdesc_has_curve25519_onion_key(node->md))
return node->md->onion_curve25519_pkey; return node->md->onion_curve25519_pkey;
else else
return NULL; return NULL;