diff --git a/src/Common/parseAddress.cpp b/src/Common/parseAddress.cpp index b398f5cff10..c99c08896ab 100644 --- a/src/Common/parseAddress.cpp +++ b/src/Common/parseAddress.cpp @@ -39,13 +39,16 @@ std::pair parseAddress(const std::string & str, UInt16 defa throw Exception(ErrorCodes::BAD_ARGUMENTS, "Illegal port prefix passed to function parseAddress: {}", port); + ++port; + UInt16 port_number; - if (!tryParse(port_number, port + 1)) + ReadBufferFromMemory port_buf(port, end - port); + if (!tryReadText(port_number, port_buf) || !port_buf.eof()) { throw Exception(ErrorCodes::BAD_ARGUMENTS, - "Illegal port passed to function parseAddress: {}", port + 1); + "Illegal port passed to function parseAddress: {}", port); } - return { std::string(begin, port), port_number }; + return { std::string(begin, port - 1), port_number }; } else if (default_port) { diff --git a/tests/queries/0_stateless/01880_remote_ipv6.sql b/tests/queries/0_stateless/01880_remote_ipv6.sql index 9d9c25addbf..057b3ad7ec6 100644 --- a/tests/queries/0_stateless/01880_remote_ipv6.sql +++ b/tests/queries/0_stateless/01880_remote_ipv6.sql @@ -4,9 +4,9 @@ SELECT * FROM remote('[::1]', system.one) FORMAT Null; 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]', system.one) FORMAT Null; -- { serverError 36 } +SELECT * FROM remote('::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 36 } -SELECT * FROM remote('[::1]::1]', system.one) FORMAT Null; -- { serverError 519 } +SELECT * FROM remote('[::1]::1]', system.one) FORMAT Null; -- { serverError 36 }