summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2012-10-17 03:24:28 -0700
committerAndrea Shepard <andrea@torproject.org>2012-10-17 03:24:28 -0700
commit35f573136da3c1b662114cfcc6369df1b5d7b98e (patch)
treeb47a9d71e3e2b32ee8529275927a0537fd9451c4
parent17442560c44e8093f9a67d7809ed799317d4d707 (diff)
downloadtor-35f573136da3c1b662114cfcc6369df1b5d7b98e.tar.gz
tor-35f573136da3c1b662114cfcc6369df1b5d7b98e.zip
Use LD_PROTOCOL rather than LD_BUG to warn about bogus reason codes that originated remotely in circuit_end_reason_to_control_string()
-rw-r--r--src/or/reasons.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/or/reasons.c b/src/or/reasons.c
index a04cd869a2..874a86774b 100644
--- a/src/or/reasons.c
+++ b/src/or/reasons.c
@@ -300,8 +300,13 @@ errno_to_orconn_end_reason(int e)
const char *
circuit_end_reason_to_control_string(int reason)
{
- if (reason >= 0 && reason & END_CIRC_REASON_FLAG_REMOTE)
+ int is_remote = 0;
+
+ if (reason >= 0 && reason & END_CIRC_REASON_FLAG_REMOTE) {
reason &= ~END_CIRC_REASON_FLAG_REMOTE;
+ is_remote = 1;
+ }
+
switch (reason) {
case END_CIRC_AT_ORIGIN:
/* This shouldn't get passed here; it's a catch-all reason. */
@@ -338,7 +343,18 @@ circuit_end_reason_to_control_string(int reason)
case END_CIRC_REASON_MEASUREMENT_EXPIRED:
return "MEASUREMENT_EXPIRED";
default:
- log_warn(LD_BUG, "Unrecognized reason code %d", (int)reason);
+ if (is_remote) {
+ /*
+ * If it's remote, it's not a bug *here*, so don't use LD_BUG, but
+ * do note that the someone we're talking to is speaking the Tor
+ * protocol with a weird accent.
+ */
+ log_warn(LD_PROTOCOL,
+ "Remote server sent bogus reason code %d", reason);
+ } else {
+ log_warn(LD_BUG,
+ "Unrecognized reason code %d", reason);
+ }
return NULL;
}
}