test(fuzz): Fix bugs that were breaking the fuzz test
This commit is contained in:
parent
447f9c6e4f
commit
162c9b7281
2 changed files with 14 additions and 14 deletions
|
@ -19,7 +19,10 @@ pub enum BasicFileOperation<'k> {
|
|||
},
|
||||
ShallowCopy(Box<FileOperation<'k>>),
|
||||
DeepCopy(Box<FileOperation<'k>>),
|
||||
MergeWithOtherFile(Box<[FileOperation<'k>]>)
|
||||
MergeWithOtherFile {
|
||||
first: Box<FileOperation<'k>>,
|
||||
rest: Box<[FileOperation<'k>]>
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Arbitrary, Clone, Debug)]
|
||||
|
@ -85,13 +88,14 @@ where
|
|||
do_operation(writer, &base, false, flush_on_finish_file)?;
|
||||
writer.deep_copy_file_from_path(&base.path, &path)?;
|
||||
}
|
||||
BasicFileOperation::MergeWithOtherFile(other_ops) => {
|
||||
BasicFileOperation::MergeWithOtherFile { first, rest } => {
|
||||
let mut other_writer = zip::ZipWriter::new(Cursor::new(Vec::new()));
|
||||
other_ops.iter().for_each(|operation| {
|
||||
let _ = do_operation(&mut other_writer, &first, false, flush_on_finish_file);
|
||||
rest.iter().for_each(|operation| {
|
||||
let _ = do_operation(
|
||||
&mut other_writer,
|
||||
&operation,
|
||||
abort,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
|
16
src/read.rs
16
src/read.rs
|
@ -329,14 +329,10 @@ impl<R> ZipArchive<R> {
|
|||
reader: R,
|
||||
central_start: u64,
|
||||
) -> ZipResult<Self> {
|
||||
if files.is_empty() {
|
||||
return Err(ZipError::InvalidArchive(
|
||||
"attempt to finalize empty zip writer into readable",
|
||||
));
|
||||
}
|
||||
/* This is where the whole file starts. */
|
||||
let (_, first_header) = files.first().unwrap();
|
||||
let initial_offset = first_header.header_start;
|
||||
let initial_offset = match files.first() {
|
||||
Some((_, file)) => file.header_start,
|
||||
None => 0,
|
||||
};
|
||||
let shared = Arc::new(zip_archive::Shared {
|
||||
files,
|
||||
offset: initial_offset,
|
||||
|
@ -368,10 +364,10 @@ impl<R: Read + Seek> ZipArchive<R> {
|
|||
&mut self,
|
||||
mut w: W,
|
||||
) -> ZipResult<IndexMap<Box<str>, ZipFileData>> {
|
||||
let mut new_files = self.shared.files.clone();
|
||||
if new_files.is_empty() {
|
||||
if self.shared.files.is_empty() {
|
||||
return Ok(IndexMap::new());
|
||||
}
|
||||
let mut new_files = self.shared.files.clone();
|
||||
/* The first file header will probably start at the beginning of the file, but zip doesn't
|
||||
* enforce that, and executable zips like PEX files will have a shebang line so will
|
||||
* definitely be greater than 0.
|
||||
|
|
Loading…
Add table
Reference in a new issue