summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@fscked.org>2012-11-19 11:30:07 -0800
committerMike Perry <mikeperry-git@fscked.org>2012-12-07 15:28:38 -0800
commit7f8cbe389d095f673bfc03437e1f7521abae698b (patch)
tree2e4e91585d6abb74a08a67d8935d9fca276ebd26 /src/or
parent428fbfc1d5616b40b90a028813151a5d62f3493c (diff)
downloadtor-7f8cbe389d095f673bfc03437e1f7521abae698b.tar.gz
tor-7f8cbe389d095f673bfc03437e1f7521abae698b.zip
Fix a crash due to NULL circ->n_chan.
Is this redundant? Can we always rely on circ->cpath->extend_info being present for origin circuits?
Diffstat (limited to 'src/or')
-rw-r--r--src/or/circuitbuild.c55
1 files changed, 46 insertions, 9 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 22f728972e..160ad3f1fe 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -1218,10 +1218,16 @@ pathbias_count_first_hop(origin_circuit_t *circ)
/* Don't count cannibalized circs for path bias */
if (!circ->has_opened) {
- entry_guard_t *guard;
+ entry_guard_t *guard = NULL;
+
+ if (circ->cpath && circ->cpath->extend_info) {
+ guard = entry_guard_get_by_id_digest(
+ circ->cpath->extend_info->identity_digest);
+ } else if (circ->base_.n_chan) {
+ guard =
+ entry_guard_get_by_id_digest(circ->base_.n_chan->identity_digest);
+ }
- guard =
- entry_guard_get_by_id_digest(circ->base_.n_chan->identity_digest);
if (guard) {
if (circ->path_state == PATH_STATE_NEW_CIRC) {
circ->path_state = PATH_STATE_DID_FIRST_HOP;
@@ -1299,8 +1305,13 @@ pathbias_count_success(origin_circuit_t *circ)
/* Don't count cannibalized/reused circs for path bias */
if (!circ->has_opened) {
- guard =
- entry_guard_get_by_id_digest(circ->base_.n_chan->identity_digest);
+ if (circ->cpath && circ->cpath->extend_info) {
+ guard = entry_guard_get_by_id_digest(
+ circ->cpath->extend_info->identity_digest);
+ } else if (circ->base_.n_chan) {
+ guard =
+ entry_guard_get_by_id_digest(circ->base_.n_chan->identity_digest);
+ }
if (guard) {
if (circ->path_state == PATH_STATE_DID_FIRST_HOP) {
@@ -1373,7 +1384,13 @@ pathbias_count_successful_close(origin_circuit_t *circ)
return;
}
- guard = entry_guard_get_by_id_digest(circ->base_.n_chan->identity_digest);
+ if (circ->cpath && circ->cpath->extend_info) {
+ guard = entry_guard_get_by_id_digest(
+ circ->cpath->extend_info->identity_digest);
+ } else if (circ->base_.n_chan) {
+ guard =
+ entry_guard_get_by_id_digest(circ->base_.n_chan->identity_digest);
+ }
if (guard) {
/* In the long run: circuit_success ~= successful_circuit_close +
@@ -1408,7 +1425,13 @@ pathbias_count_collapse(origin_circuit_t *circ)
return;
}
- guard = entry_guard_get_by_id_digest(circ->base_.n_chan->identity_digest);
+ if (circ->cpath && circ->cpath->extend_info) {
+ guard = entry_guard_get_by_id_digest(
+ circ->cpath->extend_info->identity_digest);
+ } else if (circ->base_.n_chan) {
+ guard =
+ entry_guard_get_by_id_digest(circ->base_.n_chan->identity_digest);
+ }
if (guard) {
guard->collapsed_circuits++;
@@ -1433,7 +1456,13 @@ pathbias_count_unusable(origin_circuit_t *circ)
return;
}
- guard = entry_guard_get_by_id_digest(circ->base_.n_chan->identity_digest);
+ if (circ->cpath && circ->cpath->extend_info) {
+ guard = entry_guard_get_by_id_digest(
+ circ->cpath->extend_info->identity_digest);
+ } else if (circ->base_.n_chan) {
+ guard =
+ entry_guard_get_by_id_digest(circ->base_.n_chan->identity_digest);
+ }
if (guard) {
guard->unusable_circuits++;
@@ -1458,11 +1487,19 @@ pathbias_count_unusable(origin_circuit_t *circ)
void
pathbias_count_timeout(origin_circuit_t *circ)
{
+ entry_guard_t *guard = NULL;
+
if (!pathbias_should_count(circ)) {
return;
}
- entry_guard_t *guard =
+
+ if (circ->cpath && circ->cpath->extend_info) {
+ guard = entry_guard_get_by_id_digest(
+ circ->cpath->extend_info->identity_digest);
+ } else if (circ->base_.n_chan) {
+ guard =
entry_guard_get_by_id_digest(circ->base_.n_chan->identity_digest);
+ }
if (guard) {
guard->timeouts++;