diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-10-20 12:34:02 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-10-20 13:10:20 -0400 |
commit | 98aee8472f8028260f85b69499fa892060c9534c (patch) | |
tree | 4dd57ce4752e7d92b1b57fa394740aec5a7d4248 /src/or/networkstatus.c | |
parent | f3d000f49662f7b3d94340f30fd745c58712ea2b (diff) | |
download | tor-98aee8472f8028260f85b69499fa892060c9534c.tar.gz tor-98aee8472f8028260f85b69499fa892060c9534c.zip |
Fix a read of a freed pointer while in set_current_consensus
Found by rransom while working on issue #988. Bugfix on
0.2.2.17-alpha. Fixes bug 2097.
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r-- | src/or/networkstatus.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 1d8a20be11..27049d9ef2 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -1706,6 +1706,10 @@ networkstatus_set_current_consensus(const char *consensus, if (current_consensus) { networkstatus_copy_old_consensus_info(c, current_consensus); networkstatus_vote_free(current_consensus); + /* Defensive programming : we should set current_consensus very soon, + * but we're about to call some stuff in the meantime, and leaving this + * dangling pointer around has proven to be trouble. */ + current_consensus = NULL; } } @@ -1731,13 +1735,6 @@ networkstatus_set_current_consensus(const char *consensus, download_status_failed(&consensus_dl_status[flav], 0); } - if (directory_caches_dir_info(options)) { - dirserv_set_cached_consensus_networkstatus(consensus, - flavor, - &c->digests, - c->valid_after); - } - if (flav == USABLE_CONSENSUS_FLAVOR) { current_consensus = c; c = NULL; /* Prevent free. */ @@ -1754,6 +1751,13 @@ networkstatus_set_current_consensus(const char *consensus, circuit_build_times_new_consensus_params(&circ_times, current_consensus); } + if (directory_caches_dir_info(options)) { + dirserv_set_cached_consensus_networkstatus(consensus, + flavor, + &c->digests, + c->valid_after); + } + if (!from_cache) { write_str_to_file(consensus_fname, consensus, 0); } |