Loading src/or/control.c +4 −3 Original line number Diff line number Diff line Loading @@ -1330,14 +1330,14 @@ handle_getinfo_helper(const char *question, char **answer) if (ri) { const char *body = signed_descriptor_get_body(&ri->cache_info); if (body) *answer = tor_strdup(body); *answer = tor_strndup(body, ri->cache_info.signed_descriptor_len); } } else if (!strcmpstart(question, "desc/name/")) { routerinfo_t *ri = router_get_by_nickname(question+strlen("desc/name/"),1); if (ri) { const char *body = signed_descriptor_get_body(&ri->cache_info); if (body) *answer = tor_strdup(body); *answer = tor_strndup(body, ri->cache_info.signed_descriptor_len); } } else if (!strcmp(question, "desc/all-recent")) { routerlist_t *routerlist = router_get_routerlist(); Loading @@ -1347,7 +1347,8 @@ handle_getinfo_helper(const char *question, char **answer) { const char *body = signed_descriptor_get_body(&ri->cache_info); if (body) smartlist_add(sl, tor_strdup(body)); smartlist_add(sl, tor_strndup(body, ri->cache_info.signed_descriptor_len)); }); } *answer = smartlist_join_strings(sl, "", 0, NULL); Loading src/or/directory.c +1 −1 Original line number Diff line number Diff line Loading @@ -1076,7 +1076,7 @@ connection_dir_client_reached_eof(connection_t *conn) if (which || (conn->requested_resource && !strcmpstart(conn->requested_resource, "all"))) { /* as we learn from them, we remove them from 'which' */ router_load_routers_from_string(body, 0, which); router_load_routers_from_string(body, SAVED_NOWHERE, which); directory_info_has_arrived(time(NULL), 0); } if (which) { /* mark remaining ones as failed */ Loading src/or/dirserv.c +5 −3 Original line number Diff line number Diff line Loading @@ -481,7 +481,7 @@ dirserv_add_descriptor(const char *desc, const char **msg) *msg = NULL; /* Check: is the descriptor syntactically valid? */ ri = router_parse_entry_from_string(desc, NULL); ri = router_parse_entry_from_string(desc, NULL, 1); if (!ri) { log_warn(LD_DIRSERV, "Couldn't parse uploaded server descriptor"); *msg = "Rejected: Couldn't parse server descriptor."; Loading Loading @@ -1808,6 +1808,7 @@ connection_dirserv_add_servers_to_outbuf(connection_t *conn) while (smartlist_len(conn->fingerprint_stack) && buf_datalen(conn->outbuf) < DIRSERV_BUFFER_MIN) { char *body; char *fp = smartlist_pop_last(conn->fingerprint_stack); signed_descriptor_t *sd = NULL; if (by_fp) { Loading @@ -1824,13 +1825,14 @@ connection_dirserv_add_servers_to_outbuf(connection_t *conn) tor_free(fp); if (!sd) continue; body = signed_descriptor_get_body(sd); if (conn->zlib_state) { connection_write_to_buf_zlib( conn, conn->zlib_state, sd->signed_descriptor_body, sd->signed_descriptor_len, body, sd->signed_descriptor_len, 0); } else { connection_write_to_buf(sd->signed_descriptor_body, connection_write_to_buf(body, sd->signed_descriptor_len, conn); } Loading src/or/or.h +13 −4 Original line number Diff line number Diff line Loading @@ -762,6 +762,10 @@ typedef struct cached_dir_t { int refcnt; /**< Reference count for this cached_dir_t. */ } cached_dir_t; typedef enum { SAVED_NOWHERE=0, SAVED_IN_CACHE, SAVED_IN_JOURNAL } saved_location_t; /** Information need to cache an onion router's descriptor. */ typedef struct signed_descriptor_t { char *signed_descriptor_body; Loading @@ -769,7 +773,7 @@ typedef struct signed_descriptor_t { char signed_descriptor_digest[DIGEST_LEN]; char identity_digest[DIGEST_LEN]; time_t published_on; enum { SAVED_NOWHERE=0, SAVED_IN_CACHE, SAVED_IN_JOURNAL } saved_location; saved_location_t saved_location; off_t saved_offset; } signed_descriptor_t; Loading Loading @@ -933,6 +937,9 @@ typedef struct { /** List of signed_descriptor_t for older router descriptors we're * caching. */ smartlist_t *old_routers; /** DOCDOC */ const char *mmap_descriptors; size_t mmap_descriptors_len; } routerlist_t; /** Information on router used when extending a circuit. (We don't need a Loading Loading @@ -2367,7 +2374,8 @@ int router_add_to_routerlist(routerinfo_t *router, const char **msg, int from_cache, int from_fetch); int router_load_single_router(const char *s, uint8_t purpose, const char **msg); void router_load_routers_from_string(const char *s, int from_cache, void router_load_routers_from_string(const char *s, saved_location_t saved_location, smartlist_t *requested_fingerprints); typedef enum { NS_FROM_CACHE, NS_FROM_DIR, NS_GENERATED Loading Loading @@ -2440,7 +2448,7 @@ int router_append_dirobj_signature(char *buf, size_t buf_len, crypto_pk_env_t *private_key); int router_parse_list_from_string(const char **s, smartlist_t *dest, int from_cache); saved_location_t saved_location); int router_parse_routerlist_from_directory(const char *s, routerlist_t **dest, crypto_pk_env_t *pkey, Loading @@ -2448,7 +2456,8 @@ int router_parse_routerlist_from_directory(const char *s, int write_to_cache); int router_parse_runningrouters(const char *str); int router_parse_directory(const char *str); routerinfo_t *router_parse_entry_from_string(const char *s, const char *end); routerinfo_t *router_parse_entry_from_string(const char *s, const char *end, int cache_copy); addr_policy_t *router_parse_addr_policy_from_string(const char *s, int assume_action); version_status_t tor_version_is_obsolete(const char *myversion, Loading src/or/router.c +4 −1 Original line number Diff line number Diff line Loading @@ -777,7 +777,10 @@ router_get_my_descriptor(void) const char *body; if (!router_get_my_routerinfo()) return NULL; /* Make sure this is nul-terminated. */ tor_assert(desc_routerinfo->cache_info.saved_location == SAVED_NOWHERE); body = signed_descriptor_get_body(&desc_routerinfo->cache_info); tor_assert(!body[desc_routerinfo->cache_info.signed_descriptor_len]); log_debug(LD_GENERAL,"my desc is '%s'", body); return body; } Loading Loading @@ -1187,7 +1190,7 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router, #ifdef DEBUG_ROUTER_DUMP_ROUTER_TO_STRING cp = s_tmp = s_dup = tor_strdup(s); ri_tmp = router_parse_entry_from_string(cp, NULL); ri_tmp = router_parse_entry_from_string(cp, NULL, 1); if (!ri_tmp) { log_err(LD_BUG, "We just generated a router descriptor we can't parse: <<%s>>", Loading Loading
src/or/control.c +4 −3 Original line number Diff line number Diff line Loading @@ -1330,14 +1330,14 @@ handle_getinfo_helper(const char *question, char **answer) if (ri) { const char *body = signed_descriptor_get_body(&ri->cache_info); if (body) *answer = tor_strdup(body); *answer = tor_strndup(body, ri->cache_info.signed_descriptor_len); } } else if (!strcmpstart(question, "desc/name/")) { routerinfo_t *ri = router_get_by_nickname(question+strlen("desc/name/"),1); if (ri) { const char *body = signed_descriptor_get_body(&ri->cache_info); if (body) *answer = tor_strdup(body); *answer = tor_strndup(body, ri->cache_info.signed_descriptor_len); } } else if (!strcmp(question, "desc/all-recent")) { routerlist_t *routerlist = router_get_routerlist(); Loading @@ -1347,7 +1347,8 @@ handle_getinfo_helper(const char *question, char **answer) { const char *body = signed_descriptor_get_body(&ri->cache_info); if (body) smartlist_add(sl, tor_strdup(body)); smartlist_add(sl, tor_strndup(body, ri->cache_info.signed_descriptor_len)); }); } *answer = smartlist_join_strings(sl, "", 0, NULL); Loading
src/or/directory.c +1 −1 Original line number Diff line number Diff line Loading @@ -1076,7 +1076,7 @@ connection_dir_client_reached_eof(connection_t *conn) if (which || (conn->requested_resource && !strcmpstart(conn->requested_resource, "all"))) { /* as we learn from them, we remove them from 'which' */ router_load_routers_from_string(body, 0, which); router_load_routers_from_string(body, SAVED_NOWHERE, which); directory_info_has_arrived(time(NULL), 0); } if (which) { /* mark remaining ones as failed */ Loading
src/or/dirserv.c +5 −3 Original line number Diff line number Diff line Loading @@ -481,7 +481,7 @@ dirserv_add_descriptor(const char *desc, const char **msg) *msg = NULL; /* Check: is the descriptor syntactically valid? */ ri = router_parse_entry_from_string(desc, NULL); ri = router_parse_entry_from_string(desc, NULL, 1); if (!ri) { log_warn(LD_DIRSERV, "Couldn't parse uploaded server descriptor"); *msg = "Rejected: Couldn't parse server descriptor."; Loading Loading @@ -1808,6 +1808,7 @@ connection_dirserv_add_servers_to_outbuf(connection_t *conn) while (smartlist_len(conn->fingerprint_stack) && buf_datalen(conn->outbuf) < DIRSERV_BUFFER_MIN) { char *body; char *fp = smartlist_pop_last(conn->fingerprint_stack); signed_descriptor_t *sd = NULL; if (by_fp) { Loading @@ -1824,13 +1825,14 @@ connection_dirserv_add_servers_to_outbuf(connection_t *conn) tor_free(fp); if (!sd) continue; body = signed_descriptor_get_body(sd); if (conn->zlib_state) { connection_write_to_buf_zlib( conn, conn->zlib_state, sd->signed_descriptor_body, sd->signed_descriptor_len, body, sd->signed_descriptor_len, 0); } else { connection_write_to_buf(sd->signed_descriptor_body, connection_write_to_buf(body, sd->signed_descriptor_len, conn); } Loading
src/or/or.h +13 −4 Original line number Diff line number Diff line Loading @@ -762,6 +762,10 @@ typedef struct cached_dir_t { int refcnt; /**< Reference count for this cached_dir_t. */ } cached_dir_t; typedef enum { SAVED_NOWHERE=0, SAVED_IN_CACHE, SAVED_IN_JOURNAL } saved_location_t; /** Information need to cache an onion router's descriptor. */ typedef struct signed_descriptor_t { char *signed_descriptor_body; Loading @@ -769,7 +773,7 @@ typedef struct signed_descriptor_t { char signed_descriptor_digest[DIGEST_LEN]; char identity_digest[DIGEST_LEN]; time_t published_on; enum { SAVED_NOWHERE=0, SAVED_IN_CACHE, SAVED_IN_JOURNAL } saved_location; saved_location_t saved_location; off_t saved_offset; } signed_descriptor_t; Loading Loading @@ -933,6 +937,9 @@ typedef struct { /** List of signed_descriptor_t for older router descriptors we're * caching. */ smartlist_t *old_routers; /** DOCDOC */ const char *mmap_descriptors; size_t mmap_descriptors_len; } routerlist_t; /** Information on router used when extending a circuit. (We don't need a Loading Loading @@ -2367,7 +2374,8 @@ int router_add_to_routerlist(routerinfo_t *router, const char **msg, int from_cache, int from_fetch); int router_load_single_router(const char *s, uint8_t purpose, const char **msg); void router_load_routers_from_string(const char *s, int from_cache, void router_load_routers_from_string(const char *s, saved_location_t saved_location, smartlist_t *requested_fingerprints); typedef enum { NS_FROM_CACHE, NS_FROM_DIR, NS_GENERATED Loading Loading @@ -2440,7 +2448,7 @@ int router_append_dirobj_signature(char *buf, size_t buf_len, crypto_pk_env_t *private_key); int router_parse_list_from_string(const char **s, smartlist_t *dest, int from_cache); saved_location_t saved_location); int router_parse_routerlist_from_directory(const char *s, routerlist_t **dest, crypto_pk_env_t *pkey, Loading @@ -2448,7 +2456,8 @@ int router_parse_routerlist_from_directory(const char *s, int write_to_cache); int router_parse_runningrouters(const char *str); int router_parse_directory(const char *str); routerinfo_t *router_parse_entry_from_string(const char *s, const char *end); routerinfo_t *router_parse_entry_from_string(const char *s, const char *end, int cache_copy); addr_policy_t *router_parse_addr_policy_from_string(const char *s, int assume_action); version_status_t tor_version_is_obsolete(const char *myversion, Loading
src/or/router.c +4 −1 Original line number Diff line number Diff line Loading @@ -777,7 +777,10 @@ router_get_my_descriptor(void) const char *body; if (!router_get_my_routerinfo()) return NULL; /* Make sure this is nul-terminated. */ tor_assert(desc_routerinfo->cache_info.saved_location == SAVED_NOWHERE); body = signed_descriptor_get_body(&desc_routerinfo->cache_info); tor_assert(!body[desc_routerinfo->cache_info.signed_descriptor_len]); log_debug(LD_GENERAL,"my desc is '%s'", body); return body; } Loading Loading @@ -1187,7 +1190,7 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router, #ifdef DEBUG_ROUTER_DUMP_ROUTER_TO_STRING cp = s_tmp = s_dup = tor_strdup(s); ri_tmp = router_parse_entry_from_string(cp, NULL); ri_tmp = router_parse_entry_from_string(cp, NULL, 1); if (!ri_tmp) { log_err(LD_BUG, "We just generated a router descriptor we can't parse: <<%s>>", Loading