From 29237770c9be4b3d5ff7f227bfc1cae4efdeeae4 Mon Sep 17 00:00:00 2001 From: Chris Hennick Date: Mon, 1 May 2023 16:06:42 -0700 Subject: [PATCH] Prevent sparse-file chunks from repeating zero times --- fuzz/fuzz_targets/fuzz_write.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fuzz/fuzz_targets/fuzz_write.rs b/fuzz/fuzz_targets/fuzz_write.rs index 8e57d811..88d299b2 100644 --- a/fuzz/fuzz_targets/fuzz_write.rs +++ b/fuzz/fuzz_targets/fuzz_write.rs @@ -88,7 +88,7 @@ fn do_operation(writer: &mut zip_next::ZipWriter, let mut bytes = Vec::with_capacity(part.extra_bytes.len() + 1); bytes.push(part.first_byte); bytes.extend(part.extra_bytes); - for (index, byte) in repeat(bytes.iter()).take(part.repeats).flatten().enumerate() { + for (index, byte) in repeat(bytes.iter()).take(part.repeats as usize + 1).flatten().enumerate() { sparse_file[part.start as usize + index] = *byte; } }