diff options
author | Roger Dingledine <arma@torproject.org> | 2006-10-20 23:23:19 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2006-10-20 23:23:19 +0000 |
commit | a0ec758f9e0cf8288a366dde365db253cf4d5de3 (patch) | |
tree | 85efc9ff9f93a7e042447e97f34e57eaa6d890d1 /src/or/control.c | |
parent | c9a01dea5306662820fdada79a8c1f1442dbb07c (diff) | |
download | tor-a0ec758f9e0cf8288a366dde365db253cf4d5de3.tar.gz tor-a0ec758f9e0cf8288a366dde365db253cf4d5de3.zip |
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
Diffstat (limited to 'src/or/control.c')
-rw-r--r-- | src/or/control.c | 35 |
1 files changed, 25 insertions, 10 deletions
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 <b>question</b>, 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); } } |