From d8cbd003197d54bebc8410d2e66a769ef0de6a29 Mon Sep 17 00:00:00 2001 From: youngwolf Date: Sat, 5 Sep 2020 10:51:43 +0800 Subject: [PATCH] Fix parsing of SOCKS5 reponse. --- include/ascs/tcp/proxy/socks.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ascs/tcp/proxy/socks.h b/include/ascs/tcp/proxy/socks.h index 3322429..c07d51c 100644 --- a/include/ascs/tcp/proxy/socks.h +++ b/include/ascs/tcp/proxy/socks.h @@ -205,7 +205,7 @@ private: { buff[3] = 3; buff[4] = (char) std::min(target_domain.size(), sizeof(buff) - 7); - memcpy(std::next(buff, 5), target_domain.data(), (size_t)buff[4]); + memcpy(std::next(buff, 5), target_domain.data(), (size_t) buff[4]); *((unsigned short*) std::next(buff, 5 + buff[4])) = htons(target_port); req_len = 7 + buff[4]; } @@ -332,7 +332,7 @@ private: this->force_shutdown(false); else if (!continue_read) super::connect_handler(ec); - else if (res_len > 22) + else if (res_len >= sizeof(buff)) { unified_out::info_out(ASCS_LLF " socks5 server error", this->id()); this->force_shutdown(false); -- GitLab