From b9016bd18faa5d470fad0c57985449c5d5c6fcb6 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 23 Mar 2005 08:40:11 +0000 Subject: Fix several bugs (including some crashes) related to control interface; implement missing desc/name functionality. svn:r3836 --- src/or/control.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/or/control.c') diff --git a/src/or/control.c b/src/or/control.c index 3114dbf2d..8eed8a682 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -329,7 +329,7 @@ handle_control_getconf(connection_t *conn, uint32_t body_len, const char *body) { int recognized = config_option_is_recognized(q); if (!recognized) { - send_control_error(conn, ERR_UNRECOGNIZED_CONFIG_KEY, body); + send_control_error(conn, ERR_UNRECOGNIZED_CONFIG_KEY, q); goto done; } else { struct config_line_t *answer = config_get_assigned_option(options,q); @@ -508,7 +508,7 @@ handle_control_mapaddress(connection_t *conn, uint32_t len, const char *body) } else if (!is_plausible_address(to)) { log_fn(LOG_WARN,"Skipping invalid argument '%s' in MapAddress msg",to); } else if (!strcmp(from, ".") || !strcmp(from, "0.0.0.0")) { - char *addr = addressmap_register_virtual_address( + const char *addr = addressmap_register_virtual_address( strcmp(from,".") ? RESOLVED_TYPE_HOSTNAME : RESOLVED_TYPE_IPV4, tor_strdup(to)); if (!addr) { @@ -518,7 +518,6 @@ handle_control_mapaddress(connection_t *conn, uint32_t len, const char *body) size_t anslen = strlen(addr)+strlen(to)+2; char *ans = tor_malloc(anslen); tor_snprintf(ans, anslen, "%s %s", addr, to); - tor_free(addr); smartlist_add(reply, ans); } } else { @@ -557,6 +556,10 @@ handle_getinfo_helper(const char *question, char **answer) routerinfo_t *ri = router_get_by_hexdigest(question+strlen("desc/id/")); if (ri && ri->signed_descriptor) *answer = tor_strdup(ri->signed_descriptor); + } else if (!strcmpstart(question, "desc/name/")) { + routerinfo_t *ri = router_get_by_nickname(question+strlen("desc/name/")); + if (ri && ri->signed_descriptor) + *answer = tor_strdup(ri->signed_descriptor); } else if (!strcmp(question, "network-status")) { if (list_server_status(NULL, answer) < 0) return -1; -- cgit v1.2.3