aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/fuzz
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2026-01-11 23:01:30 -1030
committermat <git@matdoes.dev>2026-01-11 23:01:30 -1030
commit736edae2ad243f6eb3e7b01ca9b6266745cdeb24 (patch)
tree3d1ae581c5a1addca1ac48febb59a29de0fb180b /azalea-protocol/fuzz
parent1accbac964168af5fa0d87cb170389f0a9d01363 (diff)
downloadazalea-drasl-736edae2ad243f6eb3e7b01ca9b6266745cdeb24.tar.xz
add fuzzer for azalea-protocol and fix a few panics
Diffstat (limited to 'azalea-protocol/fuzz')
-rw-r--r--azalea-protocol/fuzz/.gitignore4
-rw-r--r--azalea-protocol/fuzz/Cargo.toml75
-rw-r--r--azalea-protocol/fuzz/README.md10
-rw-r--r--azalea-protocol/fuzz/fuzz_targets/clientbound_config.rs10
-rw-r--r--azalea-protocol/fuzz/fuzz_targets/clientbound_game.rs10
-rw-r--r--azalea-protocol/fuzz/fuzz_targets/clientbound_handshake.rs10
-rw-r--r--azalea-protocol/fuzz/fuzz_targets/clientbound_login.rs10
-rw-r--r--azalea-protocol/fuzz/fuzz_targets/clientbound_status.rs10
-rw-r--r--azalea-protocol/fuzz/fuzz_targets/serverbound_config.rs10
-rw-r--r--azalea-protocol/fuzz/fuzz_targets/serverbound_game.rs10
-rw-r--r--azalea-protocol/fuzz/fuzz_targets/serverbound_handshake.rs10
-rw-r--r--azalea-protocol/fuzz/fuzz_targets/serverbound_login.rs10
-rw-r--r--azalea-protocol/fuzz/fuzz_targets/serverbound_status.rs10
13 files changed, 189 insertions, 0 deletions
diff --git a/azalea-protocol/fuzz/.gitignore b/azalea-protocol/fuzz/.gitignore
new file mode 100644
index 00000000..1a45eee7
--- /dev/null
+++ b/azalea-protocol/fuzz/.gitignore
@@ -0,0 +1,4 @@
+target
+corpus
+artifacts
+coverage
diff --git a/azalea-protocol/fuzz/Cargo.toml b/azalea-protocol/fuzz/Cargo.toml
new file mode 100644
index 00000000..37e4e606
--- /dev/null
+++ b/azalea-protocol/fuzz/Cargo.toml
@@ -0,0 +1,75 @@
+[package]
+name = "azalea-fuzz"
+version = "0.0.0"
+publish = false
+edition = "2024"
+
+[package.metadata]
+cargo-fuzz = true
+
+[dependencies]
+libfuzzer-sys = "0.4"
+azalea-protocol = { path = "..", default-features = false }
+
+[[bin]]
+name = "clientbound_config"
+path = "fuzz_targets/clientbound_config.rs"
+test = false
+doc = false
+bench = false
+[[bin]]
+name = "clientbound_game"
+path = "fuzz_targets/clientbound_game.rs"
+test = false
+doc = false
+bench = false
+[[bin]]
+name = "clientbound_handshake"
+path = "fuzz_targets/clientbound_handshake.rs"
+test = false
+doc = false
+bench = false
+[[bin]]
+name = "clientbound_login"
+path = "fuzz_targets/clientbound_login.rs"
+test = false
+doc = false
+bench = false
+[[bin]]
+name = "clientbound_status"
+path = "fuzz_targets/clientbound_status.rs"
+test = false
+doc = false
+bench = false
+
+
+[[bin]]
+name = "serverbound_config"
+path = "fuzz_targets/serverbound_config.rs"
+test = false
+doc = false
+bench = false
+[[bin]]
+name = "serverbound_game"
+path = "fuzz_targets/serverbound_game.rs"
+test = false
+doc = false
+bench = false
+[[bin]]
+name = "serverbound_handshake"
+path = "fuzz_targets/serverbound_handshake.rs"
+test = false
+doc = false
+bench = false
+[[bin]]
+name = "serverbound_login"
+path = "fuzz_targets/serverbound_login.rs"
+test = false
+doc = false
+bench = false
+[[bin]]
+name = "serverbound_status"
+path = "fuzz_targets/serverbound_status.rs"
+test = false
+doc = false
+bench = false
diff --git a/azalea-protocol/fuzz/README.md b/azalea-protocol/fuzz/README.md
new file mode 100644
index 00000000..42ae188c
--- /dev/null
+++ b/azalea-protocol/fuzz/README.md
@@ -0,0 +1,10 @@
+Fuzzing for `azalea-protocol`.
+
+## Usage
+
+```sh
+cargo fuzz run clientbound_game # {clientbound,serverbound}_{config,game,handshake,login,status}
+# optionally, add `-s none` for a speedup at the cost of catching less memory safety issues
+# see https://appsec.guide/docs/fuzzing/rust/cargo-fuzz/#addresssanitizer
+```
+
diff --git a/azalea-protocol/fuzz/fuzz_targets/clientbound_config.rs b/azalea-protocol/fuzz/fuzz_targets/clientbound_config.rs
new file mode 100644
index 00000000..79ffd95b
--- /dev/null
+++ b/azalea-protocol/fuzz/fuzz_targets/clientbound_config.rs
@@ -0,0 +1,10 @@
+#![no_main]
+
+use std::io::Cursor;
+
+use azalea_protocol::{packets::config::ClientboundConfigPacket, read::deserialize_packet};
+use libfuzzer_sys::fuzz_target;
+
+fuzz_target!(|data: &[u8]| {
+ let _ = deserialize_packet::<ClientboundConfigPacket>(&mut Cursor::new(data));
+});
diff --git a/azalea-protocol/fuzz/fuzz_targets/clientbound_game.rs b/azalea-protocol/fuzz/fuzz_targets/clientbound_game.rs
new file mode 100644
index 00000000..a253a859
--- /dev/null
+++ b/azalea-protocol/fuzz/fuzz_targets/clientbound_game.rs
@@ -0,0 +1,10 @@
+#![no_main]
+
+use std::io::Cursor;
+
+use azalea_protocol::{packets::game::ClientboundGamePacket, read::deserialize_packet};
+use libfuzzer_sys::fuzz_target;
+
+fuzz_target!(|data: &[u8]| {
+ let _ = deserialize_packet::<ClientboundGamePacket>(&mut Cursor::new(data));
+});
diff --git a/azalea-protocol/fuzz/fuzz_targets/clientbound_handshake.rs b/azalea-protocol/fuzz/fuzz_targets/clientbound_handshake.rs
new file mode 100644
index 00000000..84061965
--- /dev/null
+++ b/azalea-protocol/fuzz/fuzz_targets/clientbound_handshake.rs
@@ -0,0 +1,10 @@
+#![no_main]
+
+use std::io::Cursor;
+
+use azalea_protocol::{packets::handshake::ClientboundHandshakePacket, read::deserialize_packet};
+use libfuzzer_sys::fuzz_target;
+
+fuzz_target!(|data: &[u8]| {
+ let _ = deserialize_packet::<ClientboundHandshakePacket>(&mut Cursor::new(data));
+});
diff --git a/azalea-protocol/fuzz/fuzz_targets/clientbound_login.rs b/azalea-protocol/fuzz/fuzz_targets/clientbound_login.rs
new file mode 100644
index 00000000..6339fcea
--- /dev/null
+++ b/azalea-protocol/fuzz/fuzz_targets/clientbound_login.rs
@@ -0,0 +1,10 @@
+#![no_main]
+
+use std::io::Cursor;
+
+use azalea_protocol::{packets::login::ClientboundLoginPacket, read::deserialize_packet};
+use libfuzzer_sys::fuzz_target;
+
+fuzz_target!(|data: &[u8]| {
+ let _ = deserialize_packet::<ClientboundLoginPacket>(&mut Cursor::new(data));
+});
diff --git a/azalea-protocol/fuzz/fuzz_targets/clientbound_status.rs b/azalea-protocol/fuzz/fuzz_targets/clientbound_status.rs
new file mode 100644
index 00000000..38264f64
--- /dev/null
+++ b/azalea-protocol/fuzz/fuzz_targets/clientbound_status.rs
@@ -0,0 +1,10 @@
+#![no_main]
+
+use std::io::Cursor;
+
+use azalea_protocol::{packets::status::ClientboundStatusPacket, read::deserialize_packet};
+use libfuzzer_sys::fuzz_target;
+
+fuzz_target!(|data: &[u8]| {
+ let _ = deserialize_packet::<ClientboundStatusPacket>(&mut Cursor::new(data));
+});
diff --git a/azalea-protocol/fuzz/fuzz_targets/serverbound_config.rs b/azalea-protocol/fuzz/fuzz_targets/serverbound_config.rs
new file mode 100644
index 00000000..d2a13d1d
--- /dev/null
+++ b/azalea-protocol/fuzz/fuzz_targets/serverbound_config.rs
@@ -0,0 +1,10 @@
+#![no_main]
+
+use std::io::Cursor;
+
+use azalea_protocol::{packets::config::ServerboundConfigPacket, read::deserialize_packet};
+use libfuzzer_sys::fuzz_target;
+
+fuzz_target!(|data: &[u8]| {
+ let _ = deserialize_packet::<ServerboundConfigPacket>(&mut Cursor::new(data));
+});
diff --git a/azalea-protocol/fuzz/fuzz_targets/serverbound_game.rs b/azalea-protocol/fuzz/fuzz_targets/serverbound_game.rs
new file mode 100644
index 00000000..8891485c
--- /dev/null
+++ b/azalea-protocol/fuzz/fuzz_targets/serverbound_game.rs
@@ -0,0 +1,10 @@
+#![no_main]
+
+use std::io::Cursor;
+
+use azalea_protocol::{packets::game::ServerboundGamePacket, read::deserialize_packet};
+use libfuzzer_sys::fuzz_target;
+
+fuzz_target!(|data: &[u8]| {
+ let _ = deserialize_packet::<ServerboundGamePacket>(&mut Cursor::new(data));
+});
diff --git a/azalea-protocol/fuzz/fuzz_targets/serverbound_handshake.rs b/azalea-protocol/fuzz/fuzz_targets/serverbound_handshake.rs
new file mode 100644
index 00000000..be3fca35
--- /dev/null
+++ b/azalea-protocol/fuzz/fuzz_targets/serverbound_handshake.rs
@@ -0,0 +1,10 @@
+#![no_main]
+
+use std::io::Cursor;
+
+use azalea_protocol::{packets::handshake::ServerboundHandshakePacket, read::deserialize_packet};
+use libfuzzer_sys::fuzz_target;
+
+fuzz_target!(|data: &[u8]| {
+ let _ = deserialize_packet::<ServerboundHandshakePacket>(&mut Cursor::new(data));
+});
diff --git a/azalea-protocol/fuzz/fuzz_targets/serverbound_login.rs b/azalea-protocol/fuzz/fuzz_targets/serverbound_login.rs
new file mode 100644
index 00000000..e0e4a384
--- /dev/null
+++ b/azalea-protocol/fuzz/fuzz_targets/serverbound_login.rs
@@ -0,0 +1,10 @@
+#![no_main]
+
+use std::io::Cursor;
+
+use azalea_protocol::{packets::login::ServerboundLoginPacket, read::deserialize_packet};
+use libfuzzer_sys::fuzz_target;
+
+fuzz_target!(|data: &[u8]| {
+ let _ = deserialize_packet::<ServerboundLoginPacket>(&mut Cursor::new(data));
+});
diff --git a/azalea-protocol/fuzz/fuzz_targets/serverbound_status.rs b/azalea-protocol/fuzz/fuzz_targets/serverbound_status.rs
new file mode 100644
index 00000000..65429b29
--- /dev/null
+++ b/azalea-protocol/fuzz/fuzz_targets/serverbound_status.rs
@@ -0,0 +1,10 @@
+#![no_main]
+
+use std::io::Cursor;
+
+use azalea_protocol::{packets::status::ServerboundStatusPacket, read::deserialize_packet};
+use libfuzzer_sys::fuzz_target;
+
+fuzz_target!(|data: &[u8]| {
+ let _ = deserialize_packet::<ServerboundStatusPacket>(&mut Cursor::new(data));
+});