-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathfuzz_side.rs
More file actions
51 lines (45 loc) · 1.13 KB
/
fuzz_side.rs
File metadata and controls
51 lines (45 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#![no_main]
#[macro_use]
extern crate libfuzzer_sys;
use diffutilslib::side_diff::{self, Params};
use std::fs::File;
use std::io::Write;
fuzz_target!(|x: (Vec<u8>, Vec<u8>, /* usize, usize */ bool)| {
let (original, new, /* width, tabsize, */ expand) = x;
// if width == 0 || tabsize == 0 {
// return;
// }
let params = Params {
// width,
// tabsize,
expand_tabs: expand,
..Default::default()
};
let mut output_buf = vec![];
side_diff::diff(
&original,
&new,
&mut output_buf,
&Params {
width: params.width,
tabsize: params.tabsize,
expand_tabs: params.expand_tabs,
},
);
File::create("target/fuzz.file.original")
.unwrap()
.write_all(&original)
.unwrap();
File::create("target/fuzz.file.new")
.unwrap()
.write_all(&new)
.unwrap();
File::create("target/fuzz.file")
.unwrap()
.write_all(&original)
.unwrap();
File::create("target/fuzz.diff")
.unwrap()
.write_all(&output_buf)
.unwrap();
});