Repository navigation
domainRFC support ipv6(square brackets) and fix #53179 - #53506
Conversation
|
This is an automated comment for commit f550afa with description of existing statuses. It's updated for the latest CI running
|
| return std::string_view{}; | ||
| if (!has_at_symbol) | ||
| pos = colon_pos ? colon_pos : pos; | ||
| if (has_open_bracket && has_end_bracket) |
There was a problem hiding this comment.
Shouldn't we check something like has_open_bracket && !has_end_bracket as well?
There was a problem hiding this comment.
@vdimir Sure, if has_open_bracket (and !has_end_bracket),
then dot_pos will always be nullptr
(the logic dot_pos = pos; for case : '.' will never be executed),
so checkAndReturnHost will also return std::string_view{}.
So there's no need to check has_open_bracket && !has_end_bracket. In this case, it will only return std::string_view{}.
| @@ -0,0 +1,5 @@ | |||
| SELECT domainRFC('[2001:db8::1]:80') FORMAT CSV; | |||
| SELECT domainRFC('[::200]:80') FORMAT CSV; | |||
There was a problem hiding this comment.
Consider adding cases with errors, e.g. with open and not closed bracket, several brackets, empty string within brackets and similar that comes to your mind.
6d0ac50 to
3e325b1
Compare
|
"Hello, @vdimir , I have added various test scenarios that I could think of. Could you please review them again? Thank you. " |
|
@vdimir I have completed all the modifications, and I believe this pull request is now ready for review. If it's convenient for you, could you please review it again? Thank you. (Regarding the stress test check issue, it doesn't seem to be caused by my code. Should I continue updating the branch to address these issues?)" |
`getURLHostRFC` consumes the scheme prefix and then dereferences `*pos` at
domain.h:82 (`if (*pos == '[')`) before entering its bounded scan loop at
:93. For an authority that ends exactly at the prefix, `pos == end`, so that
read is one byte past the input.
That byte is uninitialised heap rather than a harmless terminator:
`ColumnString` is not zero-terminated (ColumnString.h:40),
`ColumnString::insert` appends exactly `s.size` bytes with a plain memcpy,
StringHelpers.h:82 passes exactly `offsets[i] - prev_offset` with no -1, and
`PODArrayBase::alloc` initialises only one `pad_left` element. `pos == end`
is reachable from "//" (`pos += 2`) and from "<scheme>://" (`pos += 3`), so
`SELECT domainRFC('http://')` is enough to trigger it. On an MSan build the
server aborts; the AST fuzzer hit it in Stress test (amd_msan) after
mutating `firstSignificantSubdomain` to `domainRFC` in
00381_first_significant_subdomain.sql. MSan names :93 rather than :82
because clang if-converts the bracket test, so the first branch on the
tainted byte is the loop guard.
The read has been unguarded since a2d451d (ClickHouse#53506) added IPv6 bracket
support in 2023, and is still unguarded on 25.3, 25.8 and 26.8. The
non-RFC `getURLHost` is safe because it has no dereference between the
prefix advance and its loop, which is the shape restored here; the same
one-line shape was used by the two earlier fixes to this class in this
function, ClickHouse#86171 and ClickHouse#94851. All ten user-facing RFC functions reach the
defect through this single call site, so all ten are fixed at once.
The guard is behaviour-preserving: every `pos == end` path already returned
an empty host. Measured over 30422 generated inputs against 13 URL
functions on a fixed and a reverted build, the output is byte-identical, so
no existing reference file changes.
There is no functional oracle for the defect, and none is invented here:
the MSan build is the oracle, as it was for the test added by ClickHouse#94851.
03801_domain_empty_string_msan gains nine truncated-authority queries: the
literal that fired in CI, two further `domainRFC` literals, five more
user-facing RFC entry points, and the same input behind `materialize` for
the vectorized route. The test uses more than one truncated-authority
literal because MSan does not emit the report at every input length on the
builds measured here.
Co-Authored-By: Claude Opus 5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
domainRFC support ipv6(IP literal within square brackets)
Documentation entry for user-facing changes
fix #53179
[RFC3513] or later, is distinguished by enclosing the IP literal
within square brackets ("[" and "]").
So our domainRFC (RFC 3986) perhaps should support this.