Limit Zopfli iterations in write fuzzing
This commit is contained in:
parent
26eeabe488
commit
d9c20c55c4
2 changed files with 8 additions and 2 deletions
|
@ -54,7 +54,8 @@ fn do_operation<T>(writer: &mut RefCell<zip_next::ZipWriter<T>>,
|
||||||
let name = operation.name;
|
let name = operation.name;
|
||||||
match operation.basic {
|
match operation.basic {
|
||||||
BasicFileOperation::WriteNormalFile {contents, mut options, ..} => {
|
BasicFileOperation::WriteNormalFile {contents, mut options, ..} => {
|
||||||
if contents.iter().map(Vec::len).sum::<usize>() >= u32::MAX as usize {
|
let uncompressed_size = contents.iter().map(Vec::len).sum::<usize>();
|
||||||
|
if uncompressed_size >= u32::MAX as usize {
|
||||||
options = options.large_file(true);
|
options = options.large_file(true);
|
||||||
}
|
}
|
||||||
writer.borrow_mut().start_file(name, options)?;
|
writer.borrow_mut().start_file(name, options)?;
|
||||||
|
|
|
@ -170,7 +170,7 @@ impl arbitrary::Arbitrary<'_> for FileOptions {
|
||||||
match options.compression_method {
|
match options.compression_method {
|
||||||
Deflated => {
|
Deflated => {
|
||||||
if bool::arbitrary(u)? {
|
if bool::arbitrary(u)? {
|
||||||
let level = u.int_in_range(0..=265)?;
|
let level = u.int_in_range(0..=24)?;
|
||||||
options.compression_level = Some(level);
|
options.compression_level = Some(level);
|
||||||
#[cfg(feature = "deflate-zopfli")]
|
#[cfg(feature = "deflate-zopfli")]
|
||||||
if level > Compression::best().level().try_into().unwrap() {
|
if level > Compression::best().level().try_into().unwrap() {
|
||||||
|
@ -334,6 +334,11 @@ impl FileOptions {
|
||||||
self.zopfli_buffer_size = size;
|
self.zopfli_buffer_size = size;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the compression level currently set.
|
||||||
|
pub fn get_compression_level(&self) -> Option<i32> {
|
||||||
|
self.compression_level
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for FileOptions {
|
impl Default for FileOptions {
|
||||||
|
|
Loading…
Add table
Reference in a new issue