You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9abcafb
Browse filesBrowse the repository at this point in the historyBrowse files
s2: fix LZ4 block conversion writing past dst (#1244)
* s2: stop LZ4 block conversion from writing past dst
The literal bound in the S2-output converters ignored the 1-5 byte
literal header, leaving too little room for a following copy with a
5-byte repeat (up to 8 bytes). The assembly wrote a few bytes past
cap(dst) before returning ErrDstTooSmall; the pure-Go path panicked.
Matches over ~16.8 MB chained 5-byte repeat chunks with no check, so the
overrun grew with the match length.
Tighten the existing literal bound so a copy always fits, and check the
limit only before each extra repeat chunk. The Snappy-output converters
already checked every chunk.
Add an unexported noAsm field so tests reach the pure-Go path without
build tags.
* s2: fuzz LZ4 conversion with under- and oversized dst
FuzzLZ4Block gave the converter 2*len(data)+4096 bytes, which S2 output
never comes close to, and asm writes past cap(dst) are invisible without
a guard. Convert again with every variant into need +/- a deterministic
amount up to len(data), with 16 guard bytes after cap, and check the
guard and that the result agrees with the large-dst run.
On the unfixed code this found an overrun within minutes; the input is
added to the seed corpus.
* s2: fuzz LZ4 assembly only when available
FuzzLZ4Block covers the assembly and pure-Go converters in one run, so
add the assembly variants only when hasAsm is set, and run the fuzzer in
CI without the noasm,nounsafe pass, on both amd64 and arm64.
0 commit comments