diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-10-08 09:13:09 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-05-28 10:41:49 -0400 |
commit | 006b7ce5ff2a90a517e2842fcdd716ed60a90f14 (patch) | |
tree | 80eb7ca264bc3b49e34e5fc29f0d2e2a55241438 /src/common/container.c | |
parent | 592a43910706a67048c7d05e45d35dc79712820a (diff) | |
download | tor-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/common/container.c')
-rw-r--r-- | src/common/container.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/common/container.c b/src/common/container.c index 864fd8a552..082afb51ee 100644 --- a/src/common/container.c +++ b/src/common/container.c @@ -208,6 +208,19 @@ smartlist_string_pos(const smartlist_t *sl, const char *element) return -1; } +/** If <b>element</b> is the same pointer as an element of <b>sl</b>, return + * that element's index. Otherwise, return -1. */ +int +smartlist_pos(const smartlist_t *sl, const void *element) +{ + int i; + if (!sl) return -1; + for (i=0; i < sl->num_used; i++) + if (element == sl->list[i]) + return i; + return -1; +} + /** Return true iff <b>sl</b> has some element E such that * !strcasecmp(E,<b>element</b>) */ |