From 235d2da74530e863c413305bc6efd3bec16dbc3c Mon Sep 17 00:00:00 2001 From: Chris Hennick Date: Sun, 21 May 2023 15:34:22 -0700 Subject: [PATCH] Include comments in fuzz_write --- fuzz/fuzz_targets/fuzz_write.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fuzz/fuzz_targets/fuzz_write.rs b/fuzz/fuzz_targets/fuzz_write.rs index 1f81a2ec..580105f6 100644 --- a/fuzz/fuzz_targets/fuzz_write.rs +++ b/fuzz/fuzz_targets/fuzz_write.rs @@ -76,16 +76,19 @@ fn do_operation(writer: &mut RefCell>, writer.borrow_mut().abort_file().unwrap(); } if operation.reopen { - let mut new_writer = zip_next::ZipWriter::new_append(writer.borrow_mut().finish().unwrap()).unwrap(); - assert_eq!(Ok(""), new_writer.get_comment()); + let old_comment = writer.borrow().get_raw_comment().to_owned(); + let new_writer = zip_next::ZipWriter::new_append(writer.borrow_mut().finish().unwrap()).unwrap(); + assert_eq!(&old_comment, new_writer.get_raw_comment()); *writer = new_writer.into(); } Ok(()) } -fuzz_target!(|data: Vec<(FileOperation, bool)>| { +fuzz_target!(|data: (Vec, Vec<(FileOperation, bool)>)| { + let (comment, operations) = data; let mut writer = RefCell::new(zip_next::ZipWriter::new(Cursor::new(Vec::new()))); - for (operation, abort) in data { + writer.borrow_mut().set_raw_comment(comment); + for (operation, abort) in operations { let _ = do_operation(&mut writer, operation, abort); } let _ = zip_next::ZipArchive::new(writer.borrow_mut().finish().unwrap());