diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-09-11 09:38:20 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-09-11 11:16:50 -0400 |
commit | 5595b212270215eaa020603cabbe2c7b3b34d624 (patch) | |
tree | 1ea7bd05f23d00a7f09c7b769fbd350ba36880f7 /src/feature/nodelist/routerparse.c | |
parent | e5601f14ed4384e8de1030d21cc7442df48adabe (diff) | |
download | tor-5595b212270215eaa020603cabbe2c7b3b34d624.tar.gz tor-5595b212270215eaa020603cabbe2c7b3b34d624.zip |
Consdiff: use lengths on inputs so they don't need NUL at the end
This is part of #27244, so that we can safely mmap consensus
documents.
Diffstat (limited to 'src/feature/nodelist/routerparse.c')
-rw-r--r-- | src/feature/nodelist/routerparse.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/feature/nodelist/routerparse.c b/src/feature/nodelist/routerparse.c index 73d320de40..9c51799d9b 100644 --- a/src/feature/nodelist/routerparse.c +++ b/src/feature/nodelist/routerparse.c @@ -1024,10 +1024,11 @@ router_get_router_hash(const char *s, size_t s_len, char *digest) * -1. */ int router_get_networkstatus_v3_signed_boundaries(const char *s, + size_t len, const char **start_out, const char **end_out) { - return router_get_hash_impl_helper(s, strlen(s), + return router_get_hash_impl_helper(s, len, "network-status-version", "\ndirectory-signature", ' ', LOG_INFO, @@ -1039,12 +1040,13 @@ router_get_networkstatus_v3_signed_boundaries(const char *s, * signed portion can be identified. Return 0 on success, -1 on failure. */ int router_get_networkstatus_v3_sha3_as_signed(uint8_t *digest_out, - const char *s) + const char *s, size_t len) { const char *start, *end; - if (router_get_networkstatus_v3_signed_boundaries(s, &start, &end) < 0) { + if (router_get_networkstatus_v3_signed_boundaries(s, len, + &start, &end) < 0) { start = s; - end = s + strlen(s); + end = s + len; } tor_assert(start); tor_assert(end); @@ -3415,7 +3417,8 @@ networkstatus_parse_vote_from_string(const char *s, const char **eos_out, *eos_out = NULL; if (router_get_networkstatus_v3_hashes(s, &ns_digests) || - router_get_networkstatus_v3_sha3_as_signed(sha3_as_signed, s)<0) { + router_get_networkstatus_v3_sha3_as_signed(sha3_as_signed, + s, strlen(s))<0) { log_warn(LD_DIR, "Unable to compute digest of network-status"); goto err; } |