From 78139acfae4afb6c15068e243a527a8aafc06ff2 Mon Sep 17 00:00:00 2001 From: Chris Hennick Date: Mon, 1 May 2023 16:43:38 -0700 Subject: [PATCH] Prevent WriteLarge from running with no compression --- fuzz/fuzz_targets/fuzz_write.rs | 2 +- src/write.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fuzz/fuzz_targets/fuzz_write.rs b/fuzz/fuzz_targets/fuzz_write.rs index 51d52b8a..f95eeed9 100644 --- a/fuzz/fuzz_targets/fuzz_write.rs +++ b/fuzz/fuzz_targets/fuzz_write.rs @@ -76,7 +76,7 @@ fn do_operation(writer: &mut zip_next::ZipWriter, } } FileOperation::WriteLarge {file, mut options} => { - options = options.large_file(true); + options = options.large_file(true).force_compression(); writer.start_file(file.name.to_owned(), options)?; let mut default_pattern = Vec::with_capacity(file.default_pattern_extra_bytes.len() + 1); default_pattern.push(file.default_pattern_first_byte); diff --git a/src/write.rs b/src/write.rs index 016249ee..76e5f4cf 100644 --- a/src/write.rs +++ b/src/write.rs @@ -128,6 +128,13 @@ impl FileOptions { self } + #[cfg(fuzzing)] + pub fn force_compression(mut self) { + if self.compression_method == CompressionMethod::Stored { + self.compression_method = CompressionMethod::Deflated; + } + } + /// Set the compression level for the new file /// /// `None` value specifies default compression level.