diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-06-25 10:41:15 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-06-25 10:41:15 -0400 |
commit | fce2a15ffbea9a2a54b0686c2859a1ee1039a660 (patch) | |
tree | c13bb3bb3ec8b7df8feb75479f0156d24a9168c4 /src/or/routerparse.c | |
parent | 3f336966a264d7cd7c6dab08fb85d85273f06d68 (diff) | |
parent | 03e3cf6a7aa86c74d01cebd61c9ad89200661e73 (diff) | |
download | tor-fce2a15ffbea9a2a54b0686c2859a1ee1039a660.tar.gz tor-fce2a15ffbea9a2a54b0686c2859a1ee1039a660.zip |
Merge remote-tracking branch 'origin/maint-0.2.6'
Diffstat (limited to 'src/or/routerparse.c')
-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 ae50cda248..3904671d01 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. */ @@ -4479,7 +4479,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; @@ -4488,8 +4491,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)) { |