Skip to content

Commit

Permalink
Fix splitting of IP:PORT endpoints
Browse files Browse the repository at this point in the history
Split on the first colon *from the right* to avoid badly spllitting IPv6-based
endpoints like ``[2001:db8::1]:443``.
  • Loading branch information
ivilata committed Jun 19, 2018
1 parent cf09f67 commit fc23b90
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/client.cpp
Expand Up @@ -458,7 +458,7 @@ void setup_ssl_context( ssl::context& ssl_context
static
string base_domain_from_target(const beast::string_view& target)
{
auto full_host = target.substr(0, target.find(':'));
auto full_host = target.substr(0, target.rfind(':'));
size_t dot0, dot1 = 0;
if ((dot0 = full_host.find('.')) != full_host.rfind('.'))
// Two different dots were found
Expand Down
2 changes: 1 addition & 1 deletion src/injector.cpp
Expand Up @@ -80,7 +80,7 @@ void handle_connect_request( GenericConnection& client_c

// Split CONNECT target in host and port (443 i.e. HTTPS by default).
auto hp = req["host"];
auto pos = hp.find(':');
auto pos = hp.rfind(':');
string host, port;
if (pos != string::npos) {
host = hp.substr(0, pos).to_string();
Expand Down
2 changes: 1 addition & 1 deletion src/util.h
Expand Up @@ -21,7 +21,7 @@ asio::ip::tcp::endpoint
parse_tcp_endpoint(const std::string& s, sys::error_code& ec)
{
using namespace std;
auto pos = s.find(':');
auto pos = s.rfind(':');

ec = sys::error_code();

Expand Down

0 comments on commit fc23b90

Please sign in to comment.