[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r10222: Fix bugs in extrainfo_insert, and change it to use desc_by_e (in tor/trunk: . src/or)
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] r10222: Fix bugs in extrainfo_insert, and change it to use desc_by_e (in tor/trunk: . src/or)
- From: nickm@xxxxxxxx
- Date: Sat, 19 May 2007 16:08:45 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Sat, 19 May 2007 16:08:52 -0400
- Reply-to: or-dev@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Author: nickm
Date: 2007-05-19 16:08:44 -0400 (Sat, 19 May 2007)
New Revision: 10222
Modified:
tor/trunk/
tor/trunk/src/or/routerlist.c
Log:
r12810@catbus: nickm | 2007-05-19 16:08:42 -0400
Fix bugs in extrainfo_insert, and change it to use desc_by_eid_map.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r12810] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c 2007-05-19 18:48:53 UTC (rev 10221)
+++ tor/trunk/src/or/routerlist.c 2007-05-19 20:08:44 UTC (rev 10222)
@@ -1780,32 +1780,29 @@
int r = 0;
routerinfo_t *ri = digestmap_get(rl->identity_map,
ei->cache_info.identity_digest);
+ signed_descriptor_t *sd;
extrainfo_t *ei_tmp;
routerlist_check_bug_417();
- if (!ri || routerinfo_incompatible_with_extrainfo(ri,ei)) {
- int found = 0;
- if (ei->pending_sig || ei->bad_sig) {
- extrainfo_free(ei);
+
+ if (!ri) {
+ /* This router is unknown; we can't even verify the signature. Give up.*/
+ goto done;
+ }
+ if (routerinfo_incompatible_with_extrainfo(ri, ei)) {
+ if (ei->bad_sig) /* If the signature didn't check, it's just wrong. */
goto done;
- }
- /* The signature checks out; let's see if one of the old routers
- * matches. */
- SMARTLIST_FOREACH(rl->old_routers, signed_descriptor_t *, sd, {
- if (!memcmp(ei->cache_info.identity_digest,
- sd->identity_digest, DIGEST_LEN) &&
- !memcmp(ei->cache_info.signed_descriptor_digest,
- sd->extra_info_digest, DIGEST_LEN) &&
- sd->published_on == ei->cache_info.published_on) {
- found = 1;
- break;
- }
- });
- if (!found) {
- extrainfo_free(ei);
+ sd = digestmap_get(rl->desc_by_eid_map,
+ ei->cache_info.signed_descriptor_digest);
+ if (!sd ||
+ memcmp(sd->identity_digest, ei->cache_info.identity_digest,
+ DIGEST_LEN) ||
+ sd->published_on != ei->cache_info.published_on)
goto done;
- }
}
+ /* Okay, if we make it here, we definitely have a router corresponding to
+ * this extrainfo. */
+
ei_tmp = digestmap_set(rl->extra_info_map,
ei->cache_info.signed_descriptor_digest,
ei);
@@ -1814,6 +1811,9 @@
extrainfo_free(ei_tmp);
done:
+ if (r == 0)
+ extrainfo_free(ei);
+
#ifdef DEBUG_ROUTERLIST
routerlist_assert_ok(rl);
#endif
@@ -4862,6 +4862,10 @@
tor_free(ei->pending_sig);
}
+ if (memcmp(ei->cache_info.signed_descriptor_digest,
+ ri->cache_info.extra_info_digest, DIGEST_LEN))
+ return 1; /* Digest doesn't match declared value. */
+
if (ei->cache_info.published_on < ei->cache_info.published_on)
return 1;
else if (ei->cache_info.published_on > ei->cache_info.published_on)