Skip to content

Commit

Permalink
Fix fuzz code.
Browse files Browse the repository at this point in the history
  • Loading branch information
hanbings committed Mar 26, 2024
1 parent a304ac0 commit c708429
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
9 changes: 1 addition & 8 deletions fuzz/fuzz_targets/fuzz_ed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@
#[macro_use]
extern crate libfuzzer_sys;
use diffutilslib::ed_diff;
use diffutilslib::ed_diff::DiffError;
use std::fs::{self, File};
use std::io::Write;
use std::process::Command;

fn diff_w(expected: &[u8], actual: &[u8], filename: &str) -> Result<Vec<u8>, DiffError> {
let mut output = ed_diff::diff(expected, actual)?;
writeln!(&mut output, "w {filename}").unwrap();
Ok(output)
}

fuzz_target!(|x: (Vec<u8>, Vec<u8>)| {
let (mut from, mut to) = x;
from.push(b'\n');
Expand All @@ -37,7 +30,7 @@ fuzz_target!(|x: (Vec<u8>, Vec<u8>)| {
} else {
return;
}
let diff = diff_w(&from, &to, "target/fuzz.file").unwrap();
let diff = ed_diff::diff(&from, &to, true).unwrap();
File::create("target/fuzz.file.original")
.unwrap()
.write_all(&from)
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/fuzz_normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fuzz_target!(|x: (Vec<u8>, Vec<u8>)| {
} else {
return
}*/
let diff = normal_diff::diff(&from, &to);
let diff = normal_diff::diff(&from, &to, true);
File::create("target/fuzz.file.original")
.unwrap()
.write_all(&from)
Expand Down
1 change: 1 addition & 0 deletions fuzz/fuzz_targets/fuzz_patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fuzz_target!(|x: (Vec<u8>, Vec<u8>, u8)| {
&to,
"target/fuzz.file",
context as usize,
true
);
File::create("target/fuzz.file.original")
.unwrap()
Expand Down

0 comments on commit c708429

Please sign in to comment.