Skip to content

fix(fsst): grow decode buffer to prevent out-of-bounds write#7267

Open
Noethix55555 wants to merge 1 commit into
lance-format:mainfrom
Noethix55555:fix/fsst-decode-buffer-oob
Open

fix(fsst): grow decode buffer to prevent out-of-bounds write#7267
Noethix55555 wants to merge 1 commit into
lance-format:mainfrom
Noethix55555:fix/fsst-decode-buffer-oob

Conversation

@Noethix55555

Copy link
Copy Markdown

Summary

fsst::fsst::decompress only required a 3 * input output buffer, but an FSST code byte can decode to an 8-byte symbol and the decode loop writes 8 bytes at a time through raw pointers. On data that compresses better than 3:1, honoring the documented minimum overran the buffer (a heap out-of-bounds write, observed as a segfault).

This sizes the output buffer for the worst case before decoding, then shrinks it to the real length at the end. The change is internal to the decode path and does not change results for callers that already pass a large enough buffer (in-tree callers pass 8 * input).

Closes #7266. Related: #2606.

Test

Added rust/compression/fsst/tests/buffer_bound.rs: it compresses an ~8:1 input and decompresses into the documented 3x buffer. This segfaulted before the change and round-trips correctly after. cargo test -p fsst and cargo clippy -p fsst --tests pass.

decompress only required a 3x output buffer, but an FSST code byte can expand to an 8-byte symbol and the decode loop writes 8 bytes at a time through raw pointers. On data that compresses better than 3:1, honoring the documented minimum overran the buffer (a heap out-of-bounds write, observed as a segfault). Size the output buffer for the worst case before decoding; it is shrunk to the real length afterwards.

Adds a regression test.
@github-actions github-actions Bot added the bug Something isn't working label Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FSST decompress writes out of bounds when data compresses better than 3:1

1 participant