Skip to content

Commit 3f10ff9

Browse files
committed
initial fuzzer support
1 parent ca7d016 commit 3f10ff9

File tree

6 files changed

+91
-11
lines changed

6 files changed

+91
-11
lines changed

.gitignore

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1+
12
.cargo
3+
.env
4+
.env.development
5+
.env.production
6+
.idea
7+
.log
28
.turbo
9+
.vscode
10+
artifacts
311
assets
412
build
13+
bun.lockb
14+
Cargo.lock
15+
corpus
16+
coverage
517
data
618
node_modules
19+
pnpm-lock.yaml
720
public
821
target
9-
wip
10-
bun.lockb
11-
.env
12-
.env.development
13-
.env.production
14-
.log
15-
Cargo.lock
16-
pnpm-lock.yaml
17-
.idea
18-
.vscode
22+
wip

bufferfish-rs/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[workspace]
22
resolver = "2"
3-
members = ["bufferfish", "bufferfish-derive", "bufferfish-internal"]
3+
members = ["bufferfish", "bufferfish-derive", "bufferfish-internal", "fuzz"]

bufferfish-rs/fuzz/Cargo.toml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[package]
2+
name = "bufferfish-fuzz"
3+
version = "0.0.0"
4+
publish = false
5+
edition = "2021"
6+
7+
[package.metadata]
8+
cargo-fuzz = true
9+
10+
[dependencies]
11+
libfuzzer-sys = "0.4"
12+
13+
[dependencies.bufferfish]
14+
path = "../bufferfish"
15+
16+
[[bin]]
17+
name = "bounded-bufferfish"
18+
path = "fuzz_targets/bounded_bufferfish.rs"
19+
test = false
20+
doc = false
21+
bench = false
22+
23+
[[bin]]
24+
name = "string-writer"
25+
path = "fuzz_targets/string_writer.rs"
26+
test = false
27+
doc = false
28+
bench = false
29+
30+
[[bin]]
31+
name = "unbounded-bufferfish"
32+
path = "fuzz_targets/unbounded_bufferfish.rs"
33+
test = false
34+
doc = false
35+
bench = false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![no_main]
2+
3+
use libfuzzer_sys::fuzz_target;
4+
5+
fuzz_target!(|data: &[u8]| {
6+
let mut bf = bufferfish::Bufferfish::new();
7+
8+
if let Err(_) = bf.write_raw_bytes(data) {
9+
return;
10+
}
11+
12+
if let Err(_) = bf.read_u8() {
13+
return;
14+
}
15+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![no_main]
2+
3+
use libfuzzer_sys::fuzz_target;
4+
5+
fuzz_target!(|data: &[u8]| {
6+
let mut bf = bufferfish::Bufferfish::with_capacity(0);
7+
8+
if let Ok(s) = std::str::from_utf8(data) {
9+
let _ = bf.write_string(s);
10+
}
11+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![no_main]
2+
3+
use libfuzzer_sys::fuzz_target;
4+
5+
fuzz_target!(|data: &[u8]| {
6+
let mut bf = bufferfish::Bufferfish::with_capacity(0);
7+
8+
if let Err(_) = bf.write_raw_bytes(data) {
9+
return;
10+
}
11+
12+
if let Err(_) = bf.read_u8() {
13+
return;
14+
}
15+
});

0 commit comments

Comments
 (0)