Prevent WriteLarge from running with no compression

This commit is contained in:
Chris Hennick 2023-05-01 16:43:38 -07:00
parent 8ba431d89c
commit 78139acfae
No known key found for this signature in database
GPG key ID: 25653935CC8B6C74
2 changed files with 8 additions and 1 deletions

View file

@ -76,7 +76,7 @@ fn do_operation<T>(writer: &mut zip_next::ZipWriter<T>,
} }
} }
FileOperation::WriteLarge {file, mut options} => { 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)?; writer.start_file(file.name.to_owned(), options)?;
let mut default_pattern = Vec::with_capacity(file.default_pattern_extra_bytes.len() + 1); let mut default_pattern = Vec::with_capacity(file.default_pattern_extra_bytes.len() + 1);
default_pattern.push(file.default_pattern_first_byte); default_pattern.push(file.default_pattern_first_byte);

View file

@ -128,6 +128,13 @@ impl FileOptions {
self 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 /// Set the compression level for the new file
/// ///
/// `None` value specifies default compression level. /// `None` value specifies default compression level.