authorgravatar for 4678790+dweiller@users.noreply.github.comDominic <4678790+dweiller@users.noreply.github.com> 2023-11-03 17:09:29+11:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-11-03 23:03:43-04:00
logf6de3ec963e3a7d96cd4f6c72b0f076f0437c45d
tree1bd456887034b6ac50355b4958208425fe807f2f
parent1ccc68f307d4a2208118a8798d43119d63b53e05

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.

1 files changed, 3 insertions(+), 1 deletions(-)

lib/std/compress/zstandard/decode/block.zig+3-1
......@@ -721,7 +721,9 @@ pub fn decodeBlockRingBuffer(
721721 },
722722 .rle => {
723723 if (src.len < 1) return error.MalformedRleBlock;
724 dest.writeSliceAssumeCapacity(src[0..block_size]);
724 for (0..block_size) |_| {
725 dest.writeAssumeCapacity(src[0]);
726 }
725727 consumed_count.* += 1;
726728 decode_state.written_count += block_size;
727729 return block_size;