Skip to content
Open
Prev Previous commit
Next Next commit
style: cargo fmt --manifest-path fuzz_write/Cargo.toml --
  • Loading branch information
Pr0methean committed Sep 10, 2025
commit f82157ddc1a456964790bb4b0ec06429bb3f1d84
21 changes: 13 additions & 8 deletions fuzz_write/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ impl FileOperation<'_> {

fn is_streamable(&self) -> bool {
match &self.basic {
BasicFileOperation::WriteNormalFile {options, ..} => !options.has_encryption(),
BasicFileOperation::WriteNormalFile { options, .. } => !options.has_encryption(),
BasicFileOperation::WriteDirectory(options) => !options.has_encryption(),
BasicFileOperation::WriteSymlinkWithTarget {options, ..} => !options.has_encryption(),
BasicFileOperation::WriteSymlinkWithTarget { options, .. } => !options.has_encryption(),
BasicFileOperation::ShallowCopy(base) => base.is_streamable(),
BasicFileOperation::DeepCopy(base) => base.is_streamable(),
BasicFileOperation::MergeWithOtherFile {operations, initial_junk} =>
initial_junk.is_empty() && operations.iter().all(|(op, _)| op.is_streamable()),
_ => true
BasicFileOperation::MergeWithOtherFile {
operations,
initial_junk,
} => initial_junk.is_empty() && operations.iter().all(|(op, _)| op.is_streamable()),
_ => true,
}
}
}
Expand Down Expand Up @@ -333,10 +335,13 @@ impl FuzzTestCase<'_> {
);
}
if streamable {
writeln!(stringifier, "let mut stream = writer.finish()?;\n\
writeln!(
stringifier,
"let mut stream = writer.finish()?;\n\
stream.seek(SeekFrom::Start({junk_len}))?;\n\
while read_zipfile_from_stream(&mut stream)?.is_some() {{}}")
.map_err(|_| ZipError::InvalidArchive("Failed to read from stream".into()))?;
while read_zipfile_from_stream(&mut stream)?.is_some() {{}}"
)
.map_err(|_| ZipError::InvalidArchive("Failed to read from stream".into()))?;
let mut stream = writer.finish()?;
stream.seek(SeekFrom::Start(junk_len as u64))?;
while read_zipfile_from_stream(&mut stream)?.is_some() {}
Expand Down
Loading