Skip to content

Commit 8e36945

Browse files
committed
fuzz
1 parent a69922a commit 8e36945

File tree

15 files changed

+1547
-39
lines changed

15 files changed

+1547
-39
lines changed

tansu-sans-io/CLAUDE.md

Lines changed: 525 additions & 0 deletions
Large diffs are not rendered by default.

tansu-sans-io/fuzz/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
target/
2+
corpus/
3+
artifacts/
4+
coverage/

tansu-sans-io/fuzz/Cargo.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[package]
2+
name = "tansu-sans-io-fuzz"
3+
version = "0.0.0"
4+
publish = false
5+
edition = "2024"
6+
7+
[package.metadata]
8+
cargo-fuzz = true
9+
10+
[workspace]
11+
12+
[dependencies]
13+
libfuzzer-sys = "0.4"
14+
tansu-sans-io = { path = ".." }
15+
bytes = "1"
16+
17+
[[bin]]
18+
name = "fuzz_request_decode"
19+
path = "fuzz_targets/fuzz_request_decode.rs"
20+
21+
[[bin]]
22+
name = "fuzz_response_decode"
23+
path = "fuzz_targets/fuzz_response_decode.rs"
24+
25+
[[bin]]
26+
name = "fuzz_deflated_batch"
27+
path = "fuzz_targets/fuzz_deflated_batch.rs"
28+
29+
[[bin]]
30+
name = "fuzz_varint"
31+
path = "fuzz_targets/fuzz_varint.rs"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![no_main]
2+
use bytes::Bytes;
3+
use libfuzzer_sys::fuzz_target;
4+
use tansu_sans_io::record::deflated;
5+
6+
fuzz_target!(|data: &[u8]| {
7+
let _ = deflated::Batch::try_from(Bytes::copy_from_slice(data));
8+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![no_main]
2+
use bytes::Bytes;
3+
use libfuzzer_sys::fuzz_target;
4+
use tansu_sans_io::Frame;
5+
6+
fuzz_target!(|data: &[u8]| {
7+
let _ = Frame::request_from_bytes(Bytes::copy_from_slice(data));
8+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![no_main]
2+
use bytes::Bytes;
3+
use libfuzzer_sys::fuzz_target;
4+
use tansu_sans_io::Frame;
5+
6+
fuzz_target!(|data: &[u8]| {
7+
if data.len() < 4 {
8+
return;
9+
}
10+
let api_key = i16::from_be_bytes([data[0], data[1]]);
11+
let api_version = i16::from_be_bytes([data[2], data[3]]);
12+
let payload = Bytes::copy_from_slice(&data[4..]);
13+
let _ = Frame::response_from_bytes(payload, api_key, api_version);
14+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![no_main]
2+
use bytes::Bytes;
3+
use libfuzzer_sys::fuzz_target;
4+
use tansu_sans_io::Decode;
5+
use tansu_sans_io::primitive::varint::{LongVarInt, VarInt};
6+
7+
fuzz_target!(|data: &[u8]| {
8+
let mut buf = Bytes::copy_from_slice(data);
9+
let _ = VarInt::decode(&mut buf);
10+
11+
let mut buf = Bytes::copy_from_slice(data);
12+
let _ = LongVarInt::decode(&mut buf);
13+
});

0 commit comments

Comments
 (0)