[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Sending 'Not allowed' error message before closing the connection.
commit 51e247361824fa64f4322fb59e9d2cffd9d72cba
Author: rl1987 <rl1987@xxxxxxxxxxxxxxxx>
Date: Tue Oct 21 20:50:32 2014 +0300
Sending 'Not allowed' error message before closing the connection.
---
src/or/buffers.c | 4 +++-
src/test/test_socks.c | 14 ++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 354bec6..691845e 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -2053,8 +2053,10 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
string_is_valid_ipv6_address(req->address)) {
log_unsafe_socks_warning(5,req->address,req->port,safe_socks);
- if (safe_socks)
+ if (safe_socks) {
+ socks_request_set_socks5_error(req, SOCKS5_NOT_ALLOWED);
return -1;
+ }
}
if (!string_is_valid_hostname(req->address)) {
diff --git a/src/test/test_socks.c b/src/test/test_socks.c
index ba6b9a9..a3fe07f 100644
--- a/src/test/test_socks.c
+++ b/src/test/test_socks.c
@@ -238,6 +238,13 @@ test_socks_5_supported_commands(void *ptr)
ADD_DATA(buf, "\x01\x02");
tt_assert(fetch_from_buf_socks(buf,socks,get_options()->TestSocks,1)
== -1);
+
+ tt_int_op(5,==,socks->socks_version);
+ tt_int_op(10,==,socks->replylen);
+ tt_int_op(5,==,socks->reply[0]);
+ tt_int_op(SOCKS5_NOT_ALLOWED,==,socks->reply[1]);
+ tt_int_op(1,==,socks->reply[3]);
+
socks_request_clear(socks);
/* SOCKS 5 should reject RESOLVE [F0] reject for IPv6 address
@@ -249,6 +256,13 @@ test_socks_5_supported_commands(void *ptr)
ADD_DATA(buf, "\x01\x02");
tt_assert(fetch_from_buf_socks(buf,socks,get_options()->TestSocks,1)
== -1);
+
+ tt_int_op(5,==,socks->socks_version);
+ tt_int_op(10,==,socks->replylen);
+ tt_int_op(5,==,socks->reply[0]);
+ tt_int_op(SOCKS5_NOT_ALLOWED,==,socks->reply[1]);
+ tt_int_op(1,==,socks->reply[3]);
+
socks_request_clear(socks);
/* SOCKS 5 Send RESOLVE_PTR [F1] for IP address 2.2.2.5 */
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits