Revert large-file test: impractical

This commit is contained in:
Chris Hennick 2023-05-01 17:06:37 -07:00
parent 2f4acd3900
commit 04654fdbe3
No known key found for this signature in database
GPG key ID: 25653935CC8B6C74
4 changed files with 12 additions and 60 deletions

View file

@ -90,7 +90,7 @@ jobs:
cargo fuzz build fuzz_read
- name: run fuzz
run: |
cargo fuzz run fuzz_read -- -timeout=1 -runs=10000000
cargo fuzz run fuzz_read -- -timeout=1s -runs=10000000
fuzz_write:
runs-on: ubuntu-latest
@ -109,4 +109,4 @@ jobs:
cargo fuzz build fuzz_write
- name: run fuzz
run: |
cargo fuzz run fuzz_write -- -timeout=600 -runs=1000000 -max_len=1000000 -rss_limit_mb=7000
cargo fuzz run fuzz_write -- -timeout=1s -runs=1000000 -max_len=5000000000

View file

@ -11,7 +11,6 @@ cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.4"
arbitrary = { version = "1.3.0", features = ["derive"] }
itertools = "0.10.5"
[dependencies.zip_next]
path = ".."

View file

@ -1,34 +1,21 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use arbitrary::{Arbitrary};
use std::fmt::Debug;
use arbitrary::Arbitrary;
use std::io::{Cursor, Read, Seek, Write};
use std::iter::{repeat};
#[derive(Arbitrary,Debug)]
pub struct ExtraData {
pub header_id: u16,
pub data: Vec<u8>
}
#[derive(Arbitrary,Debug)]
pub struct File {
pub name: String,
pub contents: Vec<Vec<u8>>
}
const LARGE_FILE_BUF_SIZE: usize = u32::MAX as usize + 1;
#[derive(Arbitrary, Clone, Debug)]
pub struct SparseFilePart {
pub start: u32,
pub first_byte: u8,
pub extra_bytes: Vec<u8>,
pub repeats: u8
}
#[derive(Arbitrary,Debug)]
pub struct LargeFile {
pub name: String,
pub default_pattern_first_byte: u8,
pub default_pattern_extra_bytes: Vec<u8>,
pub parts: Vec<SparseFilePart>,
pub min_extra_length: u16
pub contents: Vec<Vec<u8>>,
pub local_extra_data: Vec<ExtraData>,
pub central_extra_data: Vec<ExtraData>
}
#[derive(Arbitrary,Debug)]
@ -37,10 +24,6 @@ pub enum FileOperation {
file: File,
options: zip_next::write::FileOptions
},
WriteLarge {
file: LargeFile,
options: zip_next::write::FileOptions
},
ShallowCopy {
base: Box<FileOperation>,
new_name: String
@ -55,7 +38,6 @@ impl FileOperation {
pub fn get_name(&self) -> String {
match self {
FileOperation::Write {file, ..} => &file.name,
FileOperation::WriteLarge {file, ..} => &file.name,
FileOperation::ShallowCopy {new_name, ..} => new_name,
FileOperation::DeepCopy {new_name, ..} => new_name
}.to_owned()
@ -75,25 +57,6 @@ fn do_operation<T>(writer: &mut zip_next::ZipWriter<T>,
writer.write_all(chunk.as_slice())?;
}
}
FileOperation::WriteLarge {file, mut options} => {
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);
default_pattern.extend(&file.default_pattern_extra_bytes);
let mut sparse_file: Vec<u8> =
repeat(default_pattern.into_iter()).flatten().take(LARGE_FILE_BUF_SIZE + file.min_extra_length as usize)
.collect();
for part in &file.parts {
let mut bytes = Vec::with_capacity(part.extra_bytes.len() + 1);
bytes.push(part.first_byte);
bytes.extend(part.extra_bytes.iter());
for (index, byte) in repeat(bytes.iter()).take(part.repeats as usize + 1).flatten().enumerate() {
sparse_file[part.start as usize + index] = *byte;
}
}
writer.write_all(sparse_file.as_slice())?;
}
FileOperation::ShallowCopy {base, new_name} => {
do_operation(writer, base)?;
writer.shallow_copy_file(&base.get_name(), new_name)?;

View file

@ -128,16 +128,6 @@ impl FileOptions {
self
}
/// Changes the compression method to Deflate if it would otherwise be no compression.
#[must_use]
#[cfg(fuzzing)]
pub fn force_compression(mut self) -> FileOptions {
if self.compression_method == CompressionMethod::Stored {
self.compression_method = CompressionMethod::Deflated;
}
self
}
/// Set the compression level for the new file
///
/// `None` value specifies default compression level.