aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/read.rs
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/src/read.rs
parent1accbac964168af5fa0d87cb170389f0a9d01363 (diff)
downloadazalea-drasl-736edae2ad243f6eb3e7b01ca9b6266745cdeb24.tar.xz
add fuzzer for azalea-protocol and fix a few panics
Diffstat (limited to 'azalea-protocol/src/read.rs')
-rw-r--r--azalea-protocol/src/read.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs
index d6c8c65a..664e2593 100644
--- a/azalea-protocol/src/read.rs
+++ b/azalea-protocol/src/read.rs
@@ -401,3 +401,36 @@ where
Ok(Some(buf))
}
+
+#[cfg(test)]
+mod tests {
+ use std::io::Cursor;
+
+ use crate::{packets::game::ClientboundGamePacket, read::deserialize_packet};
+
+ #[test]
+ fn fuzzed_1() {
+ // oom: checks for unbounded TagMap
+ let _ = deserialize_packet::<ClientboundGamePacket>(&mut Cursor::new(
+ [132, 1, 255, 255, 255, 255, 255].as_slice(),
+ ));
+ }
+ #[test]
+ fn fuzzed_2() {
+ // oom: also checks for unbounded TagMap
+ let _ = deserialize_packet::<ClientboundGamePacket>(&mut Cursor::new(
+ [132, 1, 75, 0, 255, 255, 255, 255, 24, 0].as_slice(),
+ ));
+ }
+ #[test]
+ fn fuzzed_3() {
+ // panic: integer overflow in HolderSet::azalea_read
+ let _ = deserialize_packet::<ClientboundGamePacket>(&mut Cursor::new(
+ [
+ 94, 44, 157, 38, 61, 37, 37, 37, 37, 37, 37, 65, 128, 128, 1, 1, 255, 252, 128,
+ 128, 128, 128, 128, 128, 128, 40, 0,
+ ]
+ .as_slice(),
+ ));
+ }
+}