diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-10-07 16:04:24 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-10-07 16:04:24 -0400 |
commit | ab5b11fbb832cd51068060dfedc47d2a9c9f0622 (patch) | |
tree | 3ae632f5bdf7d71bd0e296292463ba779f8f42b3 /src/or/microdesc.c | |
parent | 3061a036c81cfa49a35ee06aadf525fba44ff761 (diff) | |
download | tor-ab5b11fbb832cd51068060dfedc47d2a9c9f0622.tar.gz tor-ab5b11fbb832cd51068060dfedc47d2a9c9f0622.zip |
Add a more verbose log message to try to catch bug #2022.
Diffstat (limited to 'src/or/microdesc.c')
-rw-r--r-- | src/or/microdesc.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/or/microdesc.c b/src/or/microdesc.c index 97d30ff655..6d7a61f2f5 100644 --- a/src/or/microdesc.c +++ b/src/or/microdesc.c @@ -416,7 +416,21 @@ microdesc_cache_rebuild(microdesc_cache_t *cache) SMARTLIST_FOREACH_BEGIN(wrote, microdesc_t *, md) { tor_assert(md->saved_location == SAVED_IN_CACHE); md->body = (char*)cache->cache_content->data + md->off; - tor_assert(!memcmp(md->body, "onion-key", 9)); + if (PREDICT_UNLIKELY( + md->bodylen < 9 || memcmp(md->body, "onion-key", 9) != 0)) { + /* XXXX023 once bug 2022 is solved, we can kill this block and turn it + * into just the tor_assert(!memcmp) */ + off_t avail = cache->cache_content->size - md->off; + char *bad_str; + tor_assert(avail >= 0); + bad_str = tor_strndup(md->body, MIN(128, (size_t)avail)); + log_err(LD_BUG, "After rebuilding microdesc cache, offsets seem wrong. " + " At offset %d, I expected to find a microdescriptor starting " + " with \"onion-key\". Instead I got %s.", + (int)md->off, escaped(bad_str)); + tor_free(bad_str); + tor_assert(!memcmp(md->body, "onion-key", 9)); + } } SMARTLIST_FOREACH_END(md); smartlist_free(wrote); |