aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2021-01-28 12:42:31 -0500
committerDavid Goulet <dgoulet@torproject.org>2021-01-28 12:42:31 -0500
commitf058db1f3d6fee5bc6506ece88cfd100eb86729d (patch)
tree0bc52a1c468cf69a032b3e5db2884bc2dc457a13 /src
parentf3da5f88d73f20ba1d28dde973c41e4ec45a02b6 (diff)
parent290007e3c48624060620b0340c1b4874487aab09 (diff)
downloadtor-f058db1f3d6fee5bc6506ece88cfd100eb86729d.tar.gz
tor-f058db1f3d6fee5bc6506ece88cfd100eb86729d.zip
Merge branch 'maint-0.3.5' into maint-0.4.3
Diffstat (limited to 'src')
-rw-r--r--src/core/proto/proto_socks.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/core/proto/proto_socks.c b/src/core/proto/proto_socks.c
index 4f39d69d62..0990014884 100644
--- a/src/core/proto/proto_socks.c
+++ b/src/core/proto/proto_socks.c
@@ -550,6 +550,7 @@ parse_socks5_client_request(const uint8_t *raw_data, socks_request_t *req,
if (parsed == -1) {
log_warn(LD_APP, "socks5: parsing failed - invalid client request");
res = SOCKS_RESULT_INVALID;
+ socks_request_set_socks5_error(req, SOCKS5_GENERAL_ERROR);
goto end;
} else if (parsed == -2) {
res = SOCKS_RESULT_TRUNCATED;
@@ -561,6 +562,7 @@ parse_socks5_client_request(const uint8_t *raw_data, socks_request_t *req,
if (socks5_client_request_get_version(trunnel_req) != 5) {
res = SOCKS_RESULT_INVALID;
+ socks_request_set_socks5_error(req, SOCKS5_GENERAL_ERROR);
goto end;
}
@@ -595,6 +597,7 @@ parse_socks5_client_request(const uint8_t *raw_data, socks_request_t *req,
tor_addr_to_str(req->address, &destaddr, sizeof(req->address), 1);
} break;
default: {
+ socks_request_set_socks5_error(req, SOCKS5_ADDRESS_TYPE_NOT_SUPPORTED);
res = -1;
} break;
}
@@ -775,8 +778,10 @@ handle_socks_message(const uint8_t *raw_data, size_t datalen,
} else {
res = parse_socks5_client_request(raw_data, req,
datalen, drain_out);
- if (res != SOCKS_RESULT_DONE) {
+ if (BUG(res == SOCKS_RESULT_INVALID && req->replylen == 0)) {
socks_request_set_socks5_error(req, SOCKS5_GENERAL_ERROR);
+ }
+ if (res != SOCKS_RESULT_DONE) {
goto end;
}