Skip to content

Commit 1ed8e8c

Browse files
dweillerkubkon
authored andcommitted
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 parent 63ae648 commit 1ed8e8c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/std/compress/zstandard/decode/block.zig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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;

0 commit comments

Comments
 (0)