diff options
author | David Goulet <dgoulet@torproject.org> | 2018-06-27 12:20:39 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2018-06-27 12:25:24 -0400 |
commit | 3f8a12a63a5a1d8b4d40451586377423c95bda09 (patch) | |
tree | c412d3006a13a1ac66f091272baa4f4344294750 /src/or/control.c | |
parent | f8dad5a079ac356ef72f14cfddca2d81fd824102 (diff) | |
download | tor-3f8a12a63a5a1d8b4d40451586377423c95bda09.tar.gz tor-3f8a12a63a5a1d8b4d40451586377423c95bda09.zip |
control: Make HSPOST properly parse HSADDRESS= param
For HSv3, the HSADDRESS= wasn't properly parsed for the HSPOST command. It now
correctly use it and furthermore sends back a "200 OK" in case the command is
successful for a v3 descriptor.
Fixes #26523
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/control.c')
-rw-r--r-- | src/or/control.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/or/control.c b/src/or/control.c index 028339f498..06360586ee 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -4342,8 +4342,10 @@ handle_control_hspost(control_connection_t *conn, smartlist_t *args = smartlist_new(); - /* If any SERVER= options were specified, try parse the options line */ - if (!strcasecmpstart(argline, opt_server)) { + /* If any SERVER= or HSADDRESS= options were specified, try to parse + * the options line. */ + if (!strcasecmpstart(argline, opt_server) || + !strcasecmpstart(argline, opt_hsaddress)) { /* encoded_desc begins after a newline character */ cp = cp + 1; encoded_desc = cp; @@ -4366,11 +4368,12 @@ handle_control_hspost(control_connection_t *conn, hs_dirs = smartlist_new(); smartlist_add(hs_dirs, node->rs); } else if (!strcasecmpstart(arg, opt_hsaddress)) { - if (!hs_address_is_valid(arg)) { + const char *address = arg + strlen(opt_hsaddress); + if (!hs_address_is_valid(address)) { connection_printf_to_buf(conn, "512 Malformed onion address\r\n"); goto done; } - onion_address = arg; + onion_address = address; } else { connection_printf_to_buf(conn, "512 Unexpected argument \"%s\"\r\n", arg); @@ -4385,6 +4388,8 @@ handle_control_hspost(control_connection_t *conn, read_escaped_data(encoded_desc, encoded_desc_len, &desc_str); if (hs_control_hspost_command(desc_str, onion_address, hs_dirs) < 0) { connection_printf_to_buf(conn, "554 Invalid descriptor\r\n"); + } else { + send_control_done(conn); } tor_free(desc_str); goto done; |