zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit f6de3ec963e3a7d96cd4f6c72b0f076f0437c45d (tree)
parent 1ccc68f307d4a2208118a8798d43119d63b53e05
Author: dweiller <4678790+dweiller@users.noreply.github.com>
Date:   Fri,  3 Nov 2023 17:09:29 +1100

zstandard: fix incorrect RLE decompression into ring buffer

This reverts a change introduced in #17400 causing a bug when
decompressing an RLE block into a ring buffer.

RLE blocks contain only a single byte of data to copy into the output,
so attempting to copy a slice causes buffer overruns and incorrect
decompression.

Diffstat:
Mlib/std/compress/zstandard/decode/block.zig | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/std/compress/zstandard/decode/block.zig b/lib/std/compress/zstandard/decode/block.zig @@ -721,7 +721,9 @@ pub fn decodeBlockRingBuffer( }, .rle => { if (src.len < 1) return error.MalformedRleBlock; - dest.writeSliceAssumeCapacity(src[0..block_size]); + for (0..block_size) |_| { + dest.writeAssumeCapacity(src[0]); + } consumed_count.* += 1; decode_state.written_count += block_size; return block_size;