aboutsummaryrefslogtreecommitdiff
path: root/src/or/routerparse.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-10-08 09:13:09 -0400
committerNick Mathewson <nickm@torproject.org>2015-05-28 10:41:49 -0400
commit006b7ce5ff2a90a517e2842fcdd716ed60a90f14 (patch)
tree80eb7ca264bc3b49e34e5fc29f0d2e2a55241438 /src/or/routerparse.c
parent592a43910706a67048c7d05e45d35dc79712820a (diff)
downloadtor-006b7ce5ff2a90a517e2842fcdd716ed60a90f14.tar.gz
tor-006b7ce5ff2a90a517e2842fcdd716ed60a90f14.zip
Fix the position-check for ed25519 certs to work with annotations
When there are annotations on a router descriptor, the ed25519-identity element won't be at position 0 or 1; it will be at router+1 or router-1. This patch also adds a missing smartlist function to search a list for an item with a particular pointer.
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r--src/or/routerparse.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index b3bb565e58..98104f4c08 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -1195,6 +1195,7 @@ router_parse_entry_from_string(const char *s, const char *end,
}
tok = find_by_keyword(tokens, K_ROUTER);
+ const int router_token_pos = smartlist_pos(tokens, tok);
tor_assert(tok->n_args >= 5);
router = tor_malloc_zero(sizeof(routerinfo_t));
@@ -1345,8 +1346,10 @@ router_parse_entry_from_string(const char *s, const char *end,
}
if (ed_sig_tok) {
tor_assert(ed_cert_tok && cc_tap_tok && cc_ntor_tok);
- if (ed_cert_tok != smartlist_get(tokens, 0) &&
- ed_cert_tok != smartlist_get(tokens, 1)) {
+ const int ed_cert_token_pos = smartlist_pos(tokens, ed_cert_tok);
+ if (ed_cert_token_pos == -1 || router_token_pos == -1 ||
+ (ed_cert_token_pos != router_token_pos + 1 &&
+ ed_cert_token_pos != router_token_pos - 1)) {
log_warn(LD_DIR, "Ed25519 certificate in wrong position");
goto err;
}