Repository navigation
Fix out-of-bounds read in formatRowNoNewline with empty rows - #115669
Conversation
`formatRowNoNewline` strips a trailing newline from each row by decrementing the shared write buffer position. The guard only checked the position against the start of the whole buffer, not the start of the current row. When a row is formatted to an empty result (for example, an empty string with the `RawBLOB` format), the decrement rewound into the previous row's bytes, producing non-monotonic `ColumnString` offsets and a `size_t` underflow in the string size. Downstream functions then returned incorrect results or raised a logical error. Strip the trailing newline only when the current row actually emitted at least one byte (`buffer.count` past the row start), which keeps the offsets monotonic. Also keep the cursor within the current working buffer so the decrement never moves it before the buffer start after a flush. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Workflow [PR], commit [43f7715] Summary: ✅
AI ReviewSummaryThis PR fixes Final Verdict✅ No findings. The PR looks ready to merge. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 6/6 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units7 translation units recompiled, 7 s compile time in total, 7 of them have a recent master baseline. |
…ne` with empty rows
Backport #115669 to 26.7: Fix out-of-bounds read in `formatRowNoNewline` with empty rows
Backport #115669 to 26.5: Fix out-of-bounds read in `formatRowNoNewline` with empty rows
Backport #115669 to 26.3: Fix out-of-bounds read in `formatRowNoNewline` with empty rows
Backport #115669 to 25.8: Fix out-of-bounds read in `formatRowNoNewline` with empty rows
…RowNoNewline` with empty rows
…RowNoNewline` with empty rows
…RowNoNewline` with empty rows
Backport #115669 to 26.6: Fix out-of-bounds read in `formatRowNoNewline` with empty rows
…RowNoNewline` with empty rows
OTHER: formatRowNoNewline producing an empty result -> wrong/exc. Effect in the production build a394e92: its upstream test(s) 04512_format_row_no_newline_empty_row_underflow fail on it and pass on official 26.8.8.8, run on isolated servers (evidence/fix_ci_20260925/upstream_repro/server_triage_PROD263_vs_UP2688.tsv). Upstream patch unchanged, with its test(s): 04512_format_row_no_newline_empty_row_underflow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fixes a bug in the function
formatRowNoNewline. When a row is formatted to an empty result (for example, an empty string with theRawBLOBformat), the newline-stripping logic could rewind the shared write buffer into the previous row's bytes, producing non-monotonicColumnStringoffsets and asize_tunderflow in the string size. Functions consuming the result could then return incorrect results or raise a logical error.The trailing newline is now stripped only when the current row actually emitted at least one byte, which keeps the offsets monotonic. The cursor is also kept within the current working buffer so the decrement never moves it before the buffer start after a flush.
Added a regression test in
tests/queries/0_stateless/04512_format_row_no_newline_empty_row_underflow.sql.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a bug in the function
formatRowNoNewlinethat could produce incorrect results or a logical error when a row is formatted to an empty result.Documentation entry for user-facing changes
Workflow [PR]
Sync PR [sync-upstream/pr/115669]
Version info
26.7.5.11,26.6.4.21,26.5.8.11,26.3.21.9,25.8.33.2