aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/connection_edge.c
diff options
context:
space:
mode:
authorGuinness <guinness@crans.org>2020-07-08 17:46:16 +0200
committerDavid Goulet <dgoulet@torproject.org>2020-07-08 16:20:31 -0400
commit562957e0db200ea58fcf878d61314d3a2b0c297c (patch)
tree052032020a01612ff1887976c568370ac9a1f613 /src/core/or/connection_edge.c
parent9603d8af0b36dc8faf297c2a300becebfc2f721b (diff)
downloadtor-562957e0db200ea58fcf878d61314d3a2b0c297c.tar.gz
tor-562957e0db200ea58fcf878d61314d3a2b0c297c.zip
socks: Returns 0xF6 only if BAD_HOSTNAME
This commit modifies the behavior of `parse_extended_address` in such a way that if it fails, it will always return a `BAD_HOSTNAME` value, which is then used to return the 0xF6 extended error code. This way, in any case that is not a valid v2 address, we return the 0xF6 error code, which is the expected behavior. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/core/or/connection_edge.c')
-rw-r--r--src/core/or/connection_edge.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/core/or/connection_edge.c b/src/core/or/connection_edge.c
index fc77db8334..26595003c1 100644
--- a/src/core/or/connection_edge.c
+++ b/src/core/or/connection_edge.c
@@ -1663,6 +1663,9 @@ parse_extended_hostname(char *address, hostname_type_t *type_out)
log_warn(LD_APP, "Invalid %shostname %s; rejecting",
is_onion ? "onion " : "",
safe_str_client(address));
+ if (*type_out == ONION_V3_HOSTNAME) {
+ *type_out = BAD_HOSTNAME;
+ }
return false;
}
@@ -2139,7 +2142,7 @@ connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn,
if (!parse_extended_hostname(socks->address, &addresstype)) {
control_event_client_status(LOG_WARN, "SOCKS_BAD_HOSTNAME HOSTNAME=%s",
escaped(socks->address));
- if (addresstype == ONION_V3_HOSTNAME) {
+ if (addresstype == BAD_HOSTNAME) {
conn->socks_request->socks_extended_error_code = SOCKS5_HS_BAD_ADDRESS;
}
connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);