diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-03-15 10:34:05 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-03-21 13:24:09 -0400 |
commit | b24f15a9a16acc8009c25823a127f3090b9b2edc (patch) | |
tree | 205395be2c61f6c3429d8bf4dea3da6d7a4ac734 | |
parent | beef6ed45160f096815b4ea840ff671fb484d1da (diff) | |
download | tor-b24f15a9a16acc8009c25823a127f3090b9b2edc.tar.gz tor-b24f15a9a16acc8009c25823a127f3090b9b2edc.zip |
In routers_make_ed_keys_unique, break ties for published_on
This ensures that if we can't use published_on to decide an ed,rsa
mapping, we at least decide deterministically.
Resolves 17668.T3
-rw-r--r-- | src/or/dirserv.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index ab8ddfe840..ae67e8edb7 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -2124,7 +2124,8 @@ get_possible_sybil_list(const smartlist_t *routers) } /** If there are entries in <b>routers</b> with exactly the same ed25519 keys, - * remove the older one. May alter the order of the list. */ + * remove the older one. If they are exactly the same age, remove the one + * with the greater descriptor digest. May alter the order of the list. */ static void routers_make_ed_keys_unique(smartlist_t *routers) { @@ -2139,7 +2140,12 @@ routers_make_ed_keys_unique(smartlist_t *routers) if ((ri2 = digest256map_get(by_ed_key, pk))) { /* Duplicate; must omit one. Set the omit_from_vote flag in whichever * one has the earlier published_on. */ - if (ri2->cache_info.published_on < ri->cache_info.published_on) { + const time_t ri_pub = ri->cache_info.published_on; + const time_t ri2_pub = ri2->cache_info.published_on; + if (ri2_pub < ri_pub || + (ri2_pub == ri_pub && + memcmp(ri->cache_info.signed_descriptor_digest, + ri2->cache_info.signed_descriptor_digest,DIGEST_LEN)<0)) { digest256map_set(by_ed_key, pk, ri); ri2->omit_from_vote = 1; } else { |