aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-04-18 20:30:46 -0400
committerNick Mathewson <nickm@torproject.org>2014-04-18 20:31:42 -0400
commit0fd0f5f7a9309fb90a6a4d8bad7d6399a45c7cc1 (patch)
tree0e73c1a643c96e73605de7dab5e22f6d658f70d1 /src/or
parentd1be2f5cf8afc7d94f4c69081897d7ea3da71298 (diff)
downloadtor-0fd0f5f7a9309fb90a6a4d8bad7d6399a45c7cc1.tar
tor-0fd0f5f7a9309fb90a6a4d8bad7d6399a45c7cc1.tar.gz
scan-build: Avoid crashing on BUG in circuit_get_by_rend_token_and_purpose
If we fail in circuit_get_by_rend_token_and_purpose because the circuit has no rend_info, don't try to reference fiends from its rend_info when logging an error. Bugfix on 8b9a2cb68, which is going into Tor 0.2.5.4-alpha.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/circuitlist.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index b71dc3c13..24cb9fc8d 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -1261,8 +1261,16 @@ circuit_get_by_rend_token_and_purpose(uint8_t purpose, int is_rend_circ,
circ->base_.marked_for_close)
return NULL;
- if (!circ->rendinfo ||
- ! bool_eq(circ->rendinfo->is_rend_circ, is_rend_circ) ||
+ if (!circ->rendinfo) {
+ char *t = tor_strdup(hex_str(token, REND_TOKEN_LEN));
+ log_warn(LD_BUG, "Wanted a circuit with %s:%d, but lookup returned a "
+ "circuit with no rendinfo set.",
+ safe_str(t), is_rend_circ);
+ tor_free(t);
+ return NULL;
+ }
+
+ if (! bool_eq(circ->rendinfo->is_rend_circ, is_rend_circ) ||
tor_memneq(circ->rendinfo->rend_token, token, REND_TOKEN_LEN)) {
char *t = tor_strdup(hex_str(token, REND_TOKEN_LEN));
log_warn(LD_BUG, "Wanted a circuit with %s:%d, but lookup returned %s:%d",