[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Fix a crash due to NULL circ->n_chan.
commit 7f8cbe389d095f673bfc03437e1f7521abae698b
Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date: Mon Nov 19 11:30:07 2012 -0800
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?
---
src/or/circuitbuild.c | 55 +++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 46 insertions(+), 9 deletions(-)
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 22f7289..160ad3f 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++;
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits