mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
parseAddress: improve port parsing (verify that port is a valid int)
This commit is contained in:
parent
44c85edae0
commit
1eceb5a8d3
@ -39,13 +39,16 @@ std::pair<std::string, UInt16> 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<UInt16>(port_number, port + 1))
|
||||
ReadBufferFromMemory port_buf(port, end - port);
|
||||
if (!tryReadText<UInt16>(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)
|
||||
{
|
||||
|
@ -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 }
|
||||
|
Loading…
Reference in New Issue
Block a user