Repository navigation
Conversation
ColumnFixedString::LoadBody sized its buffer as string_size_ * rows with no overflow check, so a server-declared FixedString(4611686018427387905) with 4 rows wrapped to a 4-byte buffer: Size() then reported 0 rows while At() returned views of the full declared width past the end of the buffer. ColumnTuple::LoadBody and ColumnNullable::LoadBody did not notice, because they never compare the loaded child sizes with the requested row count and ColumnTuple::Size() reports only its first element. LoadBody now throws a ProtocolError when the multiplication overflows. Tuple and Nullable also throw when an element or the nested column holds a different number of rows than was loaded; with the FixedString guard in place no fresh column read from the wire reaches that check today, so it is defence in depth for element columns that misreport their size (the tests use Nothing, whose LoadBody appends to rows it already holds).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ColumnFixedString::LoadBodysizes its buffer asstring_size_ * rowswith no overflow check. A server-declaredFixedString(4611686018427387905)with 4 rows wraps to a 4-byte buffer.Size()then reports 0 rows, butAt()still returns views of the full declared width, far past the end of the buffer.Wrapping the column hides the mismatch.
ColumnTuple::LoadBodyandColumnNullable::LoadBodynever compare the loaded child sizes with the requested row count, andColumnTuple::Size()reports only its first element. ATuple(UInt8, FixedString(4611686018427387905))orNullable(FixedString(...))block therefore loads "successfully" and reads out of bounds on access.Fix:
LoadBodythrowsProtocolErrorwhen the multiplication overflows. Tuple and Nullable also throw when an element or the nested column ends up with a different row count than was loaded. With the FixedString check in place, no fresh column read from the wire reaches that second check today. It is defence in depth for element columns that misreport their size.Reproducer: a Data block with 4 rows of
Tuple(UInt8, FixedString(4611686018427387905)), orNullable(FixedString(4611686018427387905)), followed by 4 bytes of FixedString payload.Tests:
ColumnsCase.FixedString_Load_SizeOverflow,Tuple_Load_FixedStringSizeOverflow,Tuple_Load_ElementSizeMismatch,Nullable_Load_FixedStringSizeOverflowandNullable_Load_NestedSizeMismatchfail on master. Three valid round-trip controls pass on master and here.