From a0ec758f9e0cf8288a366dde365db253cf4d5de3 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Fri, 20 Oct 2006 23:23:19 +0000 Subject: stop writing arbitrary memory out on the controller port. it's an ugly patch, but at least this way we can see that it's fixed. maybe clean up the whole "@" syntax later on. svn:r8783 --- src/or/control.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'src/or/control.c') diff --git a/src/or/control.c b/src/or/control.c index 74484fdbde..59923a6912 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -1443,8 +1443,9 @@ list_getinfo_options(void) "version The current version of Tor.\n"); // XXXX Uptodate! /* This has been hard to keep up to date. Is it worth making - * a table with names, descriptions, and functions to call, - * so there's only one place to maintain? -RD */ + * a table with names, descriptions, whether to match with + * strsmpstart, and a functions to call, so there's only one + * place to maintain? -RD */ } /** Lookup the 'getinfo' entry question, and return @@ -2887,6 +2888,7 @@ control_event_circuit_status(origin_circuit_t *circ, circuit_status_event_t tp, if (EVENT_IS_INTERESTING1(EVENT_CIRCUIT_STATUS)) { const char *status; char reason_buf[64]; + int providing_reason=0; switch (tp) { case CIRC_EVENT_LAUNCHED: status = "LAUNCHED"; break; @@ -2902,6 +2904,7 @@ control_event_circuit_status(origin_circuit_t *circ, circuit_status_event_t tp, if (tp == CIRC_EVENT_FAILED || tp == CIRC_EVENT_CLOSED) { const char *reason_str = circuit_end_reason_to_string(reason_code); char *reason = NULL; + providing_reason=1; if (!reason_str) { reason = tor_malloc(16); tor_snprintf(reason, 16, "UNKNOWN_%d", reason_code); @@ -2919,18 +2922,30 @@ control_event_circuit_status(origin_circuit_t *circ, circuit_status_event_t tp, if (EVENT_IS_INTERESTING1S(EVENT_CIRCUIT_STATUS)) { const char *sp = strlen(path) ? " " : ""; - send_control1_event_extended(EVENT_CIRCUIT_STATUS, SHORT_NAMES, - "650 CIRC %lu %s%s%s@%s\r\n", - (unsigned long)circ->global_identifier, - status, sp, path, reason_buf); + if (providing_reason) + send_control1_event_extended(EVENT_CIRCUIT_STATUS, SHORT_NAMES, + "650 CIRC %lu %s%s%s@%s\r\n", + (unsigned long)circ->global_identifier, + status, sp, path, reason_buf); + else + send_control1_event_extended(EVENT_CIRCUIT_STATUS, SHORT_NAMES, + "650 CIRC %lu %s%s%s\r\n", + (unsigned long)circ->global_identifier, + status, sp, path); } if (EVENT_IS_INTERESTING1L(EVENT_CIRCUIT_STATUS)) { char *vpath = circuit_list_path_for_controller(circ); const char *sp = strlen(vpath) ? " " : ""; - send_control1_event_extended(EVENT_CIRCUIT_STATUS, LONG_NAMES, - "650 CIRC %lu %s%s%s@%s\r\n", - (unsigned long)circ->global_identifier, - status, sp, vpath, reason_buf); + if (providing_reason) + send_control1_event_extended(EVENT_CIRCUIT_STATUS, LONG_NAMES, + "650 CIRC %lu %s%s%s@%s\r\n", + (unsigned long)circ->global_identifier, + status, sp, vpath, reason_buf); + else + send_control1_event_extended(EVENT_CIRCUIT_STATUS, LONG_NAMES, + "650 CIRC %lu %s%s%s\r\n", + (unsigned long)circ->global_identifier, + status, sp, vpath); tor_free(vpath); } } -- cgit v1.2.3-54-g00ecf