Commit f6de3ec963

dweiller <4678790+dweiller@users.noreply.github.com>
2023-11-03 07:09:29
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 1ccc68f
Changed files (1)
lib
std
compress
zstandard
decode
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;