aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock139
-rw-r--r--Cargo.toml3
-rw-r--r--azalea-inventory/src/components/mod.rs3
-rw-r--r--azalea-inventory/src/slot.rs21
-rw-r--r--azalea-protocol/fuzz/.gitignore2
-rw-r--r--azalea-protocol/fuzz/README.md6
-rw-r--r--azalea-protocol/src/packets/game/c_merchant_offers.rs13
-rw-r--r--azalea-protocol/src/packets/game/c_update_advancements.rs6
-rw-r--r--azalea-protocol/src/read.rs21
9 files changed, 124 insertions, 90 deletions
diff --git a/Cargo.lock b/Cargo.lock
index f6bb7b2e..f7f86db7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -618,9 +618,9 @@ dependencies = [
[[package]]
name = "base16ct"
-version = "0.3.0"
+version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d8b59d472eab27ade8d770dcb11da7201c11234bef9f82ce7aa517be028d462b"
+checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6"
[[package]]
name = "base64"
@@ -630,9 +630,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "base64ct"
-version = "1.8.1"
+version = "1.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0e050f626429857a27ddccb31e0aca21356bfa709c04041aefddac081a8f068a"
+checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06"
[[package]]
name = "bevy_app"
@@ -942,9 +942,9 @@ dependencies = [
[[package]]
name = "cc"
-version = "1.2.51"
+version = "1.2.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a0aeaff4ff1a90589618835a598e545176939b97874f7abc7851caa0618f203"
+checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3"
dependencies = [
"find-msvc-tools",
"jobserver",
@@ -1124,9 +1124,9 @@ dependencies = [
[[package]]
name = "const-oid"
-version = "0.10.1"
+version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0dabb6555f92fb9ee4140454eb5dcd14c7960e1225c6d1a6cc361f032947713e"
+checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"
[[package]]
name = "convert_case"
@@ -1295,9 +1295,9 @@ dependencies = [
[[package]]
name = "crypto-common"
-version = "0.2.0-rc.8"
+version = "0.2.0-rc.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e6165b8029cdc3e765b74d3548f85999ee799d5124877ce45c2c85ca78e4d4aa"
+checksum = "41b8986f836d4aeb30ccf4c9d3bd562fd716074cfd7fc4a2948359fbd21ed809"
dependencies = [
"hybrid-array",
]
@@ -1326,9 +1326,9 @@ dependencies = [
[[package]]
name = "data-encoding"
-version = "2.9.0"
+version = "2.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
+checksum = "d7a1e2f27636f116493b8b860f5546edb47c8d8f8ea73e1d2a20be88e28d1fea"
[[package]]
name = "der"
@@ -1382,7 +1382,7 @@ checksum = "ebf9423bafb058e4142194330c52273c343f8a5beb7176d052f0e73b17dd35b9"
dependencies = [
"block-buffer 0.11.0",
"const-oid",
- "crypto-common 0.2.0-rc.8",
+ "crypto-common 0.2.0-rc.9",
]
[[package]]
@@ -1523,9 +1523,9 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
[[package]]
name = "find-msvc-tools"
-version = "0.1.6"
+version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "645cbb3a84e60b7531617d5ae4e57f7e27308f6445f5abf653209ea76dec8dff"
+checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41"
[[package]]
name = "fixedbitset"
@@ -1541,13 +1541,13 @@ checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99"
[[package]]
name = "flate2"
-version = "1.1.5"
+version = "1.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bfe33edd8e85a12a67454e37f8c75e730830d83e313556ab9ebf9ee7fbeb3bfb"
+checksum = "b375d6465b98090a5f25b1c7703f3859783755aa9a80433b36e0379a3ec2f369"
dependencies = [
"crc32fast",
- "libz-rs-sys",
"miniz_oxide",
+ "zlib-rs",
]
[[package]]
@@ -1685,9 +1685,9 @@ dependencies = [
[[package]]
name = "getrandom"
-version = "0.2.16"
+version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
+checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
dependencies = [
"cfg-if",
"js-sys",
@@ -1718,9 +1718,9 @@ checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"
[[package]]
name = "glam"
-version = "0.30.9"
+version = "0.30.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bd47b05dddf0005d850e5644cae7f2b14ac3df487979dbfff3b56f20b1a6ae46"
+checksum = "19fc433e8437a212d1b6f1e68c7824af3aed907da60afa994e7f542d18d12aa9"
dependencies = [
"serde_core",
]
@@ -2032,9 +2032,9 @@ dependencies = [
[[package]]
name = "indexmap"
-version = "2.12.1"
+version = "2.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2"
+checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
dependencies = [
"equivalent",
"hashbrown",
@@ -2100,9 +2100,9 @@ checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
[[package]]
name = "jiff"
-version = "0.2.17"
+version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a87d9b8105c23642f50cbbae03d1f75d8422c5cb98ce7ee9271f7ff7505be6b8"
+checksum = "e67e8da4c49d6d9909fe03361f9b620f58898859f5c7aded68351e85e71ecf50"
dependencies = [
"jiff-static",
"log",
@@ -2113,9 +2113,9 @@ dependencies = [
[[package]]
name = "jiff-static"
-version = "0.2.17"
+version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b787bebb543f8969132630c51fd0afab173a86c6abae56ff3b9e5e3e3f9f6e58"
+checksum = "e0c84ee7f197eca9a86c6fd6cb771e55eb991632f15f2bc3ca6ec838929e6e78"
dependencies = [
"proc-macro2",
"quote",
@@ -2172,9 +2172,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libc"
-version = "0.2.178"
+version = "0.2.180"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
+checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc"
[[package]]
name = "libfuzzer-sys"
@@ -2193,15 +2193,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
[[package]]
-name = "libz-rs-sys"
-version = "0.5.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c10501e7805cee23da17c7790e59df2870c0d4043ec6d03f67d31e2b53e77415"
-dependencies = [
- "zlib-rs",
-]
-
-[[package]]
name = "litemap"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2652,9 +2643,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
-version = "1.0.104"
+version = "1.0.105"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9695f8df41bb4f3d222c95a67532365f569318332d03d5f3f67f37b20e6ebdf0"
+checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7"
dependencies = [
"unicode-ident",
]
@@ -2717,9 +2708,9 @@ dependencies = [
[[package]]
name = "quote"
-version = "1.0.42"
+version = "1.0.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
+checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a"
dependencies = [
"proc-macro2",
]
@@ -2754,7 +2745,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
dependencies = [
"rand_chacha 0.9.0",
- "rand_core 0.9.3",
+ "rand_core 0.9.4",
]
[[package]]
@@ -2785,7 +2776,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
dependencies = [
"ppv-lite86",
- "rand_core 0.9.3",
+ "rand_core 0.9.4",
]
[[package]]
@@ -2794,14 +2785,14 @@ version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
- "getrandom 0.2.16",
+ "getrandom 0.2.17",
]
[[package]]
name = "rand_core"
-version = "0.9.3"
+version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
+checksum = "4f1b3bc831f92381018fd9c6350b917c7b21f1eed35a65a51900e0e55a3d7afa"
dependencies = [
"getrandom 0.3.4",
]
@@ -2922,7 +2913,7 @@ checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
dependencies = [
"cc",
"cfg-if",
- "getrandom 0.2.16",
+ "getrandom 0.2.17",
"libc",
"untrusted",
"windows-sys 0.52.0",
@@ -2982,9 +2973,9 @@ dependencies = [
[[package]]
name = "rustls"
-version = "0.23.35"
+version = "0.23.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "533f54bc6a7d4f647e46ad909549eda97bf5afc1585190ef692b4286b198bd8f"
+checksum = "c665f33d38cea657d9614f766881e4d510e0eda4239891eea56b4cadcf01801b"
dependencies = [
"aws-lc-rs",
"once_cell",
@@ -3152,9 +3143,9 @@ dependencies = [
[[package]]
name = "serde_json"
-version = "1.0.148"
+version = "1.0.149"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3084b546a1dd6289475996f182a22aba973866ea8e8b02c51d9f46b1336a22da"
+checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
dependencies = [
"itoa",
"memchr",
@@ -3177,9 +3168,9 @@ dependencies = [
[[package]]
name = "serdect"
-version = "0.4.1"
+version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d3ef0e35b322ddfaecbc60f34ab448e157e48531288ee49fafbb053696b8ffe2"
+checksum = "9af4a3e75ebd5599b30d4de5768e00b5095d518a79fefc3ecbaf77e665d1ec06"
dependencies = [
"base16ct",
"serde",
@@ -3261,8 +3252,7 @@ dependencies = [
[[package]]
name = "simdnbt"
version = "0.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3260d6b36af95a09a37b0c6f33d6e0c55387ddfcb165c1bf17d948850a53c3c4"
+source = "git+https://github.com/azalea-rs/simdnbt#3bdc57cd04f291fbd557d9f6f3481bea75894c53"
dependencies = [
"byteorder",
"flate2",
@@ -3275,8 +3265,7 @@ dependencies = [
[[package]]
name = "simdnbt-derive"
version = "0.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e9b1c2b979a5d5ce4dcaa0e7fb9077836e92931a79a625b97b6cab8534bf761a"
+source = "git+https://github.com/azalea-rs/simdnbt#3bdc57cd04f291fbd557d9f6f3481bea75894c53"
dependencies = [
"proc-macro2",
"quote",
@@ -3403,9 +3392,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "syn"
-version = "2.0.112"
+version = "2.0.114"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "21f182278bf2d2bcb3c88b1b08a37df029d71ce3d3ae26168e3c653b213b99d4"
+checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a"
dependencies = [
"proc-macro2",
"quote",
@@ -3524,9 +3513,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
-version = "1.48.0"
+version = "1.49.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408"
+checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86"
dependencies = [
"bytes",
"libc",
@@ -3562,9 +3551,9 @@ dependencies = [
[[package]]
name = "tokio-util"
-version = "0.7.17"
+version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2efa149fe76073d6e8fd97ef4f4eca7b67f599660115591483572e406e165594"
+checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098"
dependencies = [
"bytes",
"futures-core",
@@ -3605,9 +3594,9 @@ dependencies = [
[[package]]
name = "tower"
-version = "0.5.2"
+version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9"
+checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4"
dependencies = [
"futures-core",
"futures-util",
@@ -3776,9 +3765,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
name = "url"
-version = "2.5.7"
+version = "2.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "08bc136a29a3d1758e07a9cca267be308aeebf5cfd5a10f3f67ab2097683ef5b"
+checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"
dependencies = [
"form_urlencoded",
"idna",
@@ -4357,18 +4346,18 @@ dependencies = [
[[package]]
name = "zerocopy"
-version = "0.8.31"
+version = "0.8.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3"
+checksum = "668f5168d10b9ee831de31933dc111a459c97ec93225beb307aed970d1372dfd"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
-version = "0.8.31"
+version = "0.8.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a"
+checksum = "2c7962b26b0a8685668b671ee4b54d007a67d4eaf05fda79ac0ecf41e32270f1"
dependencies = [
"proc-macro2",
"quote",
@@ -4443,6 +4432,6 @@ checksum = "40990edd51aae2c2b6907af74ffb635029d5788228222c4bb811e9351c0caad3"
[[package]]
name = "zmij"
-version = "1.0.8"
+version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "317f17ff091ac4515f17cc7a190d2769a8c9a96d227de5d64b500b01cda8f2cd"
+checksum = "ac93432f5b761b22864c774aac244fa5c0fd877678a4c37ebf6cf42208f9c9ec"
diff --git a/Cargo.toml b/Cargo.toml
index 824bac90..be37529d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -82,7 +82,8 @@ sha1 = "0.11.0-rc.3"
sha2 = "0.11.0-rc.3"
# TODO: Remove when rsa is fixed.
signature = "=3.0.0-rc.5"
-simdnbt = "0.9.0"
+# simdnbt = "0.9.0"
+simdnbt = { git = "https://github.com/azalea-rs/simdnbt" }
socks5-impl = "0.8.0"
syn = "2.0.112"
thiserror = "2.0.17"
diff --git a/azalea-inventory/src/components/mod.rs b/azalea-inventory/src/components/mod.rs
index bc2a8f20..5e055592 100644
--- a/azalea-inventory/src/components/mod.rs
+++ b/azalea-inventory/src/components/mod.rs
@@ -128,7 +128,8 @@ macro_rules! define_data_components {
Ok(match kind {
$( DataComponentKind::$x => {
- Self { $x: ManuallyDrop::new($x::azalea_read(buf)?) }
+ let v = $x::azalea_read(buf)?;
+ Self { $x: ManuallyDrop::new(v) }
}, )*
})
}
diff --git a/azalea-inventory/src/slot.rs b/azalea-inventory/src/slot.rs
index 78f0cbf8..92dd40b1 100644
--- a/azalea-inventory/src/slot.rs
+++ b/azalea-inventory/src/slot.rs
@@ -359,7 +359,12 @@ impl DataComponentPatch {
kind: DataComponentKind,
value: Option<DataComponentUnion>,
) {
- self.components.insert(kind, value);
+ let existing = self.components.insert(kind, value);
+ if let Some(Some(mut existing)) = existing {
+ // SAFETY: we just got it from self.components, so it must already be the
+ // correct type
+ unsafe { existing.drop_as(kind) };
+ }
}
}
@@ -384,21 +389,23 @@ impl AzaleaRead for DataComponentPatch {
return Ok(DataComponentPatch::default());
}
- let mut components = IndexMap::new();
+ let mut components = DataComponentPatch::default();
+
for _ in 0..components_with_data_count {
let component_kind = DataComponentKind::azalea_read(buf)?;
let component_data = DataComponentUnion::azalea_read_as(component_kind, buf)?;
- components.insert(component_kind, Some(component_data));
+ // SAFETY: it must be of the correct type because we just read using
+ // azalea_read_as
+ unsafe { components.unchecked_insert_component(component_kind, Some(component_data)) };
}
for _ in 0..components_without_data_count {
let component_kind = DataComponentKind::azalea_read(buf)?;
- components.insert(component_kind, None);
+ // SAFETY: the value is None so the kind doesn't matter anyways
+ unsafe { components.unchecked_insert_component(component_kind, None) };
}
- Ok(DataComponentPatch {
- components: Box::new(components),
- })
+ Ok(components)
}
}
diff --git a/azalea-protocol/fuzz/.gitignore b/azalea-protocol/fuzz/.gitignore
index 1a45eee7..7a68a04b 100644
--- a/azalea-protocol/fuzz/.gitignore
+++ b/azalea-protocol/fuzz/.gitignore
@@ -2,3 +2,5 @@ target
corpus
artifacts
coverage
+
+fuzz-*.log \ No newline at end of file
diff --git a/azalea-protocol/fuzz/README.md b/azalea-protocol/fuzz/README.md
index df18e8ea..28b1cf4b 100644
--- a/azalea-protocol/fuzz/README.md
+++ b/azalea-protocol/fuzz/README.md
@@ -11,11 +11,13 @@ Additionally, you should be aware that this fuzzer only targets `azalea-protocol
```sh
cargo install cargo-fuzz
-cargo fuzz run clientbound_game -s none -- -rss_limit_mb=16384
+cargo fuzz run clientbound_game -s none -- -rss_limit_mb=16384 -malloc_limit_mb=1024
# other valid targets: {clientbound,serverbound}_{config,game,handshake,login,status}
# note: the rss_limit_mb is increased (from the default of 2048) so libfuzzer
# doesn't oom due to the branchiness of the code :(
-# also see https://appsec.guide/docs/fuzzing/rust/cargo-fuzz/#addresssanitizer
+# also, the `-s none` is there for increased performance, but at the cost of catching less bugs. feel free to remove it.
+
+# also see https://appsec.guide/docs/fuzzing/rust/cargo-fuzz/
```
diff --git a/azalea-protocol/src/packets/game/c_merchant_offers.rs b/azalea-protocol/src/packets/game/c_merchant_offers.rs
index 7bbf92c4..957060b4 100644
--- a/azalea-protocol/src/packets/game/c_merchant_offers.rs
+++ b/azalea-protocol/src/packets/game/c_merchant_offers.rs
@@ -2,6 +2,7 @@ use std::{
any::Any,
fmt::{self, Debug},
io::{self, Cursor, Write},
+ mem::ManuallyDrop,
};
use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite, BufReadError};
@@ -54,8 +55,13 @@ impl ItemCost {
pub fn into_item_stack(self) -> ItemStackData {
let mut component_patch = DataComponentPatch::default();
for component in self.components.expected {
+ let component = ManuallyDrop::new(component);
+ // SAFETY: DataComponentUnion does not run any destructors unless it's dropped
+ // through drop_as, so since TypedDataComponent is now ManuallyDrop, the value
+ // will stay in memory.
+ let value = unsafe { std::ptr::read(&component.value) };
unsafe {
- component_patch.unchecked_insert_component(component.kind, Some(component.value));
+ component_patch.unchecked_insert_component(component.kind, Some(value));
}
}
// TODO: add a fast way to iterate over default components, and insert the ones
@@ -129,6 +135,11 @@ impl Clone for TypedDataComponent {
}
}
}
+impl Drop for TypedDataComponent {
+ fn drop(&mut self) {
+ unsafe { self.value.drop_as(self.kind) };
+ }
+}
impl PartialEq for TypedDataComponent {
fn eq(&self, other: &Self) -> bool {
if self.kind != other.kind {
diff --git a/azalea-protocol/src/packets/game/c_update_advancements.rs b/azalea-protocol/src/packets/game/c_update_advancements.rs
index 62881b9d..24baebc5 100644
--- a/azalea-protocol/src/packets/game/c_update_advancements.rs
+++ b/azalea-protocol/src/packets/game/c_update_advancements.rs
@@ -22,7 +22,7 @@ pub struct ClientboundUpdateAdvancements {
#[derive(AzBuf, Clone, Debug, PartialEq)]
pub struct Advancement {
pub parent_id: Option<Identifier>,
- pub display: Option<DisplayInfo>,
+ pub display: Option<Box<DisplayInfo>>,
pub requirements: Vec<Vec<String>>,
pub sends_telemetry_event: bool,
}
@@ -134,7 +134,7 @@ mod tests {
id: Identifier::new("minecraft:test"),
value: Advancement {
parent_id: None,
- display: Some(DisplayInfo {
+ display: Some(Box::new(DisplayInfo {
title: FormattedText::from("title".to_owned()),
description: FormattedText::from("description".to_owned()),
icon: ItemStack::Empty,
@@ -144,7 +144,7 @@ mod tests {
background: None,
x: 0.0,
y: 0.0,
- }),
+ })),
requirements: Vec::new(),
sends_telemetry_event: false,
},
diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs
index 664e2593..5ec7f3b9 100644
--- a/azalea-protocol/src/read.rs
+++ b/azalea-protocol/src/read.rs
@@ -406,6 +406,8 @@ where
mod tests {
use std::io::Cursor;
+ use azalea_buf::AzaleaRead as _;
+
use crate::{packets::game::ClientboundGamePacket, read::deserialize_packet};
#[test]
@@ -433,4 +435,23 @@ mod tests {
.as_slice(),
));
}
+ #[test]
+ fn fuzzed_4() {
+ // memory leak in DataComponentPatch
+ let _ = deserialize_packet::<ClientboundGamePacket>(&mut Cursor::new(
+ [94, 94, 70, 52, 0, 6, 0].as_slice(),
+ ));
+ }
+ #[test]
+ fn fuzzed_5() {
+ // also a memory leak in DataComponentPatch
+ let _ = deserialize_packet::<ClientboundGamePacket>(&mut Cursor::new(
+ [94, 94, 70, 52, 0, 6, 0, 6, 0].as_slice(),
+ ));
+ }
+ #[test]
+ fn fuzzed_6() {
+ // memory leak in simdnbt
+ let _ = simdnbt::owned::Nbt::azalea_read(&mut Cursor::new([10, 10, 0, 0, 0].as_slice()));
+ }
}