diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-06-25 10:40:58 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-06-25 10:40:58 -0400 |
commit | 03e3cf6a7aa86c74d01cebd61c9ad89200661e73 (patch) | |
tree | d7e558a1e47105585c80ce26915c8dc3727d592d /src/or | |
parent | f18ee7fc7287e9d5f55c7c6c2007a8a1c2466a3e (diff) | |
parent | e0b7598833238766b157f8eb799f448dac4c1283 (diff) | |
download | tor-03e3cf6a7aa86c74d01cebd61c9ad89200661e73.tar.gz tor-03e3cf6a7aa86c74d01cebd61c9ad89200661e73.zip |
Merge remote-tracking branch 'public/bug16400_026' into maint-0.2.6
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/routerparse.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 9c6651292c..dcf419798a 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2001 Matej Pfajfar. + /* Copyright (c) 2001 Matej Pfajfar. * Copyright (c) 2001-2004, Roger Dingledine. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. * Copyright (c) 2007-2015, The Tor Project, Inc. */ @@ -4165,7 +4165,10 @@ microdescs_parse_from_string(const char *s, const char *eos, { const char *cp = tor_memstr(s, start_of_next_microdesc-s, "onion-key"); - tor_assert(cp); + const int no_onion_key = (cp == NULL); + if (no_onion_key) { + cp = s; /* So that we have *some* junk to put in the body */ + } md->bodylen = start_of_next_microdesc - cp; md->saved_location = where; @@ -4174,8 +4177,13 @@ microdescs_parse_from_string(const char *s, const char *eos, else md->body = (char*)cp; md->off = cp - start; + crypto_digest256(md->digest, md->body, md->bodylen, DIGEST_SHA256); + if (no_onion_key) { + log_fn(LOG_PROTOCOL_WARN, LD_DIR, "Malformed or truncated descriptor"); + goto next; + } } - crypto_digest256(md->digest, md->body, md->bodylen, DIGEST_SHA256); + if (tokenize_string(area, s, start_of_next_microdesc, tokens, microdesc_token_table, flags)) { |