diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-02-27 15:34:02 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-02-27 15:34:02 -0500 |
commit | 937b5cdd41b03a6e05af4003a444172e3e88a31d (patch) | |
tree | 45e64a43d551816d0d7a5a443a19ada1f90dc2a4 | |
parent | 1c39dbd53a4c47ac3bfd6770d0ca2f8f058f888b (diff) | |
parent | b67657bd952919d0b738a1ffd6c48cc369604873 (diff) | |
download | tor-937b5cdd41b03a6e05af4003a444172e3e88a31d.tar tor-937b5cdd41b03a6e05af4003a444172e3e88a31d.tar.gz |
Merge remote branch 'origin/maint-0.2.1'
Conflicts:
ChangeLog
src/or/routerparse.c
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | src/or/circuitbuild.c | 2 | ||||
-rw-r--r-- | src/or/or.h | 2 | ||||
-rw-r--r-- | src/or/router.c | 3 | ||||
-rw-r--r-- | src/or/routerlist.c | 2 | ||||
-rw-r--r-- | src/or/routerparse.c | 50 |
6 files changed, 46 insertions, 28 deletions
@@ -108,6 +108,21 @@ Changes in version 0.2.2.9-alpha - 2010-02-22 open() without checking it. +Changes in version 0.2.1.25 - 2010-??-?? + o Major bugfixes: + - When freeing a cipher, zero it out completely. We only zeroed + the first ptrsize bytes. Bugfix on tor-0.0.2pre8. Discovered + and patched by ekir. Fixes bug 1254. + o Minor bugfixes: + - Fix a dereference-then-NULL-check sequence when publishing + descriptors. Bugfix on tor-0.2.1.5-alpha. Discovered by ekir, + fixes bug 1255. + - Fix another dereference-then-NULL-check sequence. Bugfix on + 0.2.1.14-rc. Discovered by ekir, fixes bug 1256. + - Make sure we treat potentially not NUL-terminated strings correctly. + Bugfix on 0.1.1.13-alpha. Discovered by rieo, fixes bug 1257. + + Changes in version 0.2.1.24 - 2010-02-21 Tor 0.2.1.24 makes Tor work again on the latest OS X -- this time for sure! diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 5780e6dcd..8004c3861 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -1110,11 +1110,11 @@ circuit_list_path_impl(origin_circuit_t *circ, int verbose, int verbose_names) const char *id; if (!hop) break; - id = hop->extend_info->identity_digest; if (!verbose && hop->state != CPATH_STATE_OPEN) break; if (!hop->extend_info) break; + id = hop->extend_info->identity_digest; if (verbose_names) { elt = tor_malloc(MAX_VERBOSE_NICKNAME_LEN+1); if ((ri = router_get_by_digest(id))) { diff --git a/src/or/or.h b/src/or/or.h index 428195cb2..52197f24f 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -5146,7 +5146,7 @@ typedef struct tor_version_t { char git_tag[DIGEST_LEN]; } tor_version_t; -int router_get_router_hash(const char *s, char *digest); +int router_get_router_hash(const char *s, size_t s_len, char *digest); int router_get_dir_hash(const char *s, char *digest); int router_get_runningrouters_hash(const char *s, char *digest); int router_get_networkstatus_v2_hash(const char *s, char *digest); diff --git a/src/or/router.c b/src/or/router.c index 257bca935..2c7e4dc5d 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1416,6 +1416,7 @@ router_rebuild_descriptor(int force) ei->cache_info.send_unencrypted = 1; router_get_router_hash(ri->cache_info.signed_descriptor_body, + strlen(ri->cache_info.signed_descriptor_body), ri->cache_info.signed_descriptor_digest); routerinfo_set_country(ri); @@ -1778,7 +1779,7 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router, strlcpy(s+written, "router-signature\n", maxlen-written); written += strlen(s+written); s[written] = '\0'; - if (router_get_router_hash(s, digest) < 0) { + if (router_get_router_hash(s, strlen(s), digest) < 0) { return -1; } diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 80229f214..5f1aa4208 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -583,8 +583,6 @@ signed_desc_append_to_journal(signed_descriptor_t *desc, const char *body = signed_descriptor_get_body_impl(desc,1); size_t len = desc->signed_descriptor_len + desc->annotations_len; - tor_assert(len == strlen(body)); - if (append_bytes_to_file(fname, body, len, 1)) { log_warn(LD_FS, "Unable to store router descriptor"); tor_free(fname); diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 940a2d83e..39bb932d0 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -520,11 +520,12 @@ static int router_add_exit_policy(routerinfo_t *router,directory_token_t *tok); static addr_policy_t *router_parse_addr_policy(directory_token_t *tok); static addr_policy_t *router_parse_addr_policy_private(directory_token_t *tok); -static int router_get_hash_impl(const char *s, char *digest, +static int router_get_hash_impl(const char *s, size_t s_len, char *digest, const char *start_str, const char *end_str, char end_char, digest_algorithm_t alg); -static int router_get_hashes_impl(const char *s, digests_t *digests, +static int router_get_hashes_impl(const char *s, size_t s_len, + digests_t *digests, const char *start_str, const char *end_str, char end_char); static void token_clear(directory_token_t *tok); @@ -606,7 +607,7 @@ dump_desc(const char *desc, const char *type) int router_get_dir_hash(const char *s, char *digest) { - return router_get_hash_impl(s,digest, + return router_get_hash_impl(s, strlen(s), digest, "signed-directory","\ndirectory-signature",'\n', DIGEST_SHA1); } @@ -615,9 +616,9 @@ router_get_dir_hash(const char *s, char *digest) * <b>s</b>. Return 0 on success, -1 on failure. */ int -router_get_router_hash(const char *s, char *digest) +router_get_router_hash(const char *s, size_t s_len, char *digest) { - return router_get_hash_impl(s,digest, + return router_get_hash_impl(s, s_len, digest, "router ","\nrouter-signature", '\n', DIGEST_SHA1); } @@ -628,7 +629,7 @@ router_get_router_hash(const char *s, char *digest) int router_get_runningrouters_hash(const char *s, char *digest) { - return router_get_hash_impl(s,digest, + return router_get_hash_impl(s, strlen(s), digest, "network-status","\ndirectory-signature", '\n', DIGEST_SHA1); } @@ -638,7 +639,7 @@ router_get_runningrouters_hash(const char *s, char *digest) int router_get_networkstatus_v2_hash(const char *s, char *digest) { - return router_get_hash_impl(s,digest, + return router_get_hash_impl(s, strlen(s), digest, "network-status-version","\ndirectory-signature", '\n', DIGEST_SHA1); @@ -649,7 +650,7 @@ router_get_networkstatus_v2_hash(const char *s, char *digest) int router_get_networkstatus_v3_hashes(const char *s, digests_t *digests) { - return router_get_hashes_impl(s,digests, + return router_get_hashes_impl(s,strlen(s),digests, "network-status-version", "\ndirectory-signature", ' '); @@ -661,7 +662,7 @@ int router_get_networkstatus_v3_hash(const char *s, char *digest, digest_algorithm_t alg) { - return router_get_hash_impl(s,digest, + return router_get_hash_impl(s, strlen(s), digest, "network-status-version", "\ndirectory-signature", ' ', alg); @@ -672,8 +673,8 @@ router_get_networkstatus_v3_hash(const char *s, char *digest, int router_get_extrainfo_hash(const char *s, char *digest) { - return router_get_hash_impl(s,digest,"extra-info","\nrouter-signature",'\n', - DIGEST_SHA1); + return router_get_hash_impl(s, strlen(s), digest, "extra-info", + "\nrouter-signature",'\n', DIGEST_SHA1); } /** Helper: used to generate signatures for routers, directories and @@ -1242,6 +1243,8 @@ dump_distinct_digest_count(int severity) * s through end into the signed_descriptor_body of the resulting * routerinfo_t. * + * If <b>end</b> is NULL, <b>s</b> must be properly NULL-terminated. + * * If <b>allow_annotations</b>, it's okay to encounter annotations in <b>s</b> * before the router; if it's false, reject the router if it's annotated. If * <b>prepend_annotations</b> is set, it should contain some annotations: @@ -1304,7 +1307,7 @@ router_parse_entry_from_string(const char *s, const char *end, } } - if (router_get_router_hash(s, digest) < 0) { + if (router_get_router_hash(s, end - s, digest) < 0) { log_warn(LD_DIR, "Couldn't compute router hash."); goto err; } @@ -1726,7 +1729,7 @@ authority_cert_parse_from_string(const char *s, const char **end_of_string) log_warn(LD_DIR, "Error tokenizing key certificate"); goto err; } - if (router_get_hash_impl(s, digest, "dir-key-certificate-version", + if (router_get_hash_impl(s, strlen(s), digest, "dir-key-certificate-version", "\ndir-key-certification", '\n', DIGEST_SHA1) < 0) goto err; tok = smartlist_get(tokens, 0); @@ -4065,13 +4068,13 @@ find_all_exitpolicy(smartlist_t *s) } static int -router_get_hash_impl_helper(const char *s, +router_get_hash_impl_helper(const char *s, size_t s_len, const char *start_str, const char *end_str, char end_c, const char **start_out, const char **end_out) { - char *start, *end; - start = strstr(s, start_str); + const char *start, *end; + start = tor_memstr(s, s_len, start_str); if (!start) { log_warn(LD_DIR,"couldn't find start of hashed material \"%s\"",start_str); return -1; @@ -4082,12 +4085,13 @@ router_get_hash_impl_helper(const char *s, start_str); return -1; } - end = strstr(start+strlen(start_str), end_str); + end = tor_memstr(start+strlen(start_str), + s_len - (start-s) - strlen(start_str), end_str); if (!end) { log_warn(LD_DIR,"couldn't find end of hashed material \"%s\"",end_str); return -1; } - end = strchr(end+strlen(end_str), end_c); + end = memchr(end+strlen(end_str), end_c, s_len - (end-s) - strlen(end_str)); if (!end) { log_warn(LD_DIR,"couldn't find EOL"); return -1; @@ -4107,13 +4111,13 @@ router_get_hash_impl_helper(const char *s, * If no such substring exists, return -1. */ static int -router_get_hash_impl(const char *s, char *digest, +router_get_hash_impl(const char *s, size_t s_len, char *digest, const char *start_str, const char *end_str, char end_c, digest_algorithm_t alg) { const char *start=NULL, *end=NULL; - if (router_get_hash_impl_helper(s,start_str,end_str,end_c,&start,&end)<0) + if (router_get_hash_impl_helper(s,s_len,start_str,end_str,end_c,&start,&end)<0) return -1; if (alg == DIGEST_SHA1) { @@ -4133,12 +4137,12 @@ router_get_hash_impl(const char *s, char *digest, /** As router_get_hash_impl, but compute all hashes. */ static int -router_get_hashes_impl(const char *s, digests_t *digests, +router_get_hashes_impl(const char *s, size_t s_len, digests_t *digests, const char *start_str, const char *end_str, char end_c) { const char *start=NULL, *end=NULL; - if (router_get_hash_impl_helper(s,start_str,end_str,end_c,&start,&end)<0) + if (router_get_hash_impl_helper(s,s_len,start_str,end_str,end_c,&start,&end)<0) return -1; if (crypto_digest_all(digests, start, end-start)) { @@ -4556,7 +4560,7 @@ rend_parse_v2_service_descriptor(rend_service_descriptor_t **parsed_out, goto err; } /* Compute descriptor hash for later validation. */ - if (router_get_hash_impl(desc, desc_hash, + if (router_get_hash_impl(desc, strlen(desc), desc_hash, "rendezvous-service-descriptor ", "\nsignature", '\n', DIGEST_SHA1) < 0) { log_warn(LD_REND, "Couldn't compute descriptor hash."); |