diff options
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/control.c | 13 | ||||
-rw-r--r-- | src/or/dirserv.c | 3 | ||||
-rw-r--r-- | src/or/or.h | 1 | ||||
-rw-r--r-- | src/or/router.c | 13 |
4 files changed, 27 insertions, 3 deletions
diff --git a/src/or/control.c b/src/or/control.c index 5b0d7c2ca..fb4af9112 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -1523,8 +1523,17 @@ getinfo_helper_dir(control_connection_t *control_conn, if (strlen(question) == HEX_DIGEST_LEN) { char d[DIGEST_LEN]; signed_descriptor_t *sd = NULL; - if (base16_decode(d, sizeof(d), question, strlen(question))==0) - sd = extrainfo_get_by_descriptor_digest(d); + if (base16_decode(d, sizeof(d), question, strlen(question))==0) { + /* XXXX this test should move into extrainfo_get_by_descriptor_digest, + * but I don't want to risk affecting other parts of the code, + * especially since the rules for using our own extrainfo (including + * when it might be freed) are different from those for using one + * we have downloaded. */ + if (router_extrainfo_digest_is_me(d)) + sd = &(router_get_my_extrainfo()->cache_info); + else + sd = extrainfo_get_by_descriptor_digest(d); + } if (sd) { const char *body = signed_descriptor_get_body(sd); if (body) diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 5570a3905..29aff2872 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -2673,7 +2673,8 @@ dirserv_get_routerdescs(smartlist_t *descs_out, const char *key, SMARTLIST_FOREACH(digests, const char *, d, { if (router_digest_is_me(d)) { - smartlist_add(descs_out, &(router_get_my_routerinfo()->cache_info)); + if (router_get_my_routerinfo()) /* make sure desc_routerinfo exists */ + smartlist_add(descs_out, &(router_get_my_routerinfo()->cache_info)); } else { routerinfo_t *ri = router_get_by_digest(d); /* Don't actually serve a descriptor that everyone will think is diff --git a/src/or/or.h b/src/or/or.h index f7af3e7c9..b00b4dd9c 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3794,6 +3794,7 @@ routerinfo_t *router_get_my_routerinfo(void); extrainfo_t *router_get_my_extrainfo(void); const char *router_get_my_descriptor(void); int router_digest_is_me(const char *digest); +int router_extrainfo_digest_is_me(const char *digest); int router_is_me(routerinfo_t *router); int router_fingerprint_is_me(const char *fp); int router_pick_published_address(or_options_t *options, uint32_t *addr); diff --git a/src/or/router.c b/src/or/router.c index 2a2493998..9b22d86ed 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1094,6 +1094,19 @@ router_digest_is_me(const char *digest) return identitykey && !memcmp(identitykey_digest, digest, DIGEST_LEN); } +/** Return true iff I'm a server and <b>digest</b> is equal to + * my identity digest. */ +int +router_extrainfo_digest_is_me(const char *digest) +{ + if (!router_get_my_extrainfo()) + return 0; + + return !memcmp(digest, + &(router_get_my_extrainfo()->cache_info).signed_descriptor_digest, + DIGEST_LEN); +} + /** A wrapper around router_digest_is_me(). */ int router_is_me(routerinfo_t *router) |