parseAddress: improve parsing of port for IPv6

This commit is contained in:
Azat Khuzhin 2021-05-20 21:02:45 +03:00
parent 09020242b2
commit 44c85edae0
2 changed files with 9 additions and 1 deletions

View File

@ -28,13 +28,17 @@ std::pair<std::string, UInt16> parseAddress(const std::string & str, UInt16 defa
throw Exception("Illegal address passed to function parseAddress: "
"the address begins with opening square bracket, but no closing square bracket found", ErrorCodes::BAD_ARGUMENTS);
port = find_first_symbols<':'>(closing_square_bracket + 1, end);
port = closing_square_bracket + 1;
}
else
port = find_first_symbols<':'>(begin, end);
if (port != end)
{
if (*port != ':')
throw Exception(ErrorCodes::BAD_ARGUMENTS,
"Illegal port prefix passed to function parseAddress: {}", port);
UInt16 port_number;
if (!tryParse<UInt16>(port_number, port + 1))
{

View File

@ -6,3 +6,7 @@ SELECT * FROM remote('[::1]:9000', system.one) FORMAT Null;
SELECT * FROM remote('[::1', system.one) FORMAT Null; -- { serverError 36 }
SELECT * FROM remote('::1]', system.one) FORMAT Null; -- { serverError 519 }
SELECT * FROM remote('::1', system.one) FORMAT Null; -- { serverError 519 }
SELECT * FROM remote('[::1][::1]', system.one) FORMAT Null; -- { serverError 36 }
SELECT * FROM remote('[::1][::1', system.one) FORMAT Null; -- { serverError 36 }
SELECT * FROM remote('[::1]::1]', system.one) FORMAT Null; -- { serverError 519 }