From aa19afbcd087943aedf09f85954c2b5d710662cd Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 25 Sep 2026 13:40:56 +0000 Subject: [PATCH] M1: dalek 4, fuzzing and fixes, tsc-model with server flavor - curve25519-dalek-ng -> curve25519-dalek 4. - fuzz/: cargo-fuzz targets for packets, commands and the license chain, plus a nightly workflow. Fixes for the panics they found: empty license, unchecked license property bounds, wrong index in the C2S audio invalid-codec error. - tsc-model: ServerVersion/ServerFlavor/Capabilities parsed from virtualserver_version; tsctl shows the flavor in the tree header. - CI lints every non-vendored crate via scripts/own-crates.sh. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G --- .github/workflows/ci.yml | 4 +- .github/workflows/fuzz.yml | 33 + Cargo.lock | 74 +- Cargo.toml | 3 + crates/proto/UPSTREAM.md | 9 + crates/proto/tsproto-packets/src/packets.rs | 12 +- crates/proto/tsproto-types/Cargo.toml | 2 +- crates/proto/tsproto-types/src/crypto.rs | 8 +- crates/proto/tsproto/Cargo.toml | 2 +- crates/proto/tsproto/examples/test-ed25519.rs | 4 +- crates/proto/tsproto/src/algorithms.rs | 2 +- crates/proto/tsproto/src/license.rs | 34 +- crates/tsc-model/Cargo.toml | 18 + crates/tsc-model/src/lib.rs | 8 + crates/tsc-model/src/server.rs | 138 ++ fuzz/.gitignore | 4 + fuzz/Cargo.lock | 1431 +++++++++++++++++ fuzz/Cargo.toml | 38 + fuzz/fuzz_targets/command.rs | 24 + fuzz/fuzz_targets/license.rs | 11 + fuzz/fuzz_targets/packet.rs | 15 + scripts/own-crates.sh | 9 + tools/tsctl/Cargo.toml | 1 + tools/tsctl/src/tree.rs | 8 +- 24 files changed, 1835 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/fuzz.yml create mode 100644 crates/tsc-model/Cargo.toml create mode 100644 crates/tsc-model/src/lib.rs create mode 100644 crates/tsc-model/src/server.rs create mode 100644 fuzz/.gitignore create mode 100644 fuzz/Cargo.lock create mode 100644 fuzz/Cargo.toml create mode 100644 fuzz/fuzz_targets/command.rs create mode 100644 fuzz/fuzz_targets/license.rs create mode 100644 fuzz/fuzz_targets/packet.rs create mode 100755 scripts/own-crates.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e2dfd4..c2f4c22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,9 +29,9 @@ jobs: # and have known clippy findings (cleanup is milestone M1), so the strict # checks cover our own crates only. - name: rustfmt (own crates) - run: cargo fmt -p tsctl --check + run: cargo fmt $(scripts/own-crates.sh) --check - name: clippy (own crates, deny warnings) - run: cargo clippy -p tsctl --all-targets --no-deps -- -D warnings + run: cargo clippy $(scripts/own-crates.sh) --all-targets --no-deps -- -D warnings - name: clippy (workspace, report only) run: cargo clippy --workspace --all-targets diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml new file mode 100644 index 0000000..8f4fc75 --- /dev/null +++ b/.github/workflows/fuzz.yml @@ -0,0 +1,33 @@ +name: Fuzz + +on: + schedule: + - cron: "17 3 * * *" + workflow_dispatch: + +jobs: + fuzz: + name: fuzz ${{ matrix.target }} + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + target: [packet, command, license] + steps: + - uses: actions/checkout@v4 + - name: Install nightly and cargo-fuzz + run: | + rustup toolchain install nightly --profile minimal + cargo install cargo-fuzz --locked + - uses: Swatinem/rust-cache@v2 + with: + workspaces: fuzz + - name: Fuzz for 10 minutes + working-directory: fuzz + run: cargo +nightly fuzz run ${{ matrix.target }} -- -max_total_time=600 + - name: Upload crash artifacts + if: failure() + uses: actions/upload-artifact@v4 + with: + name: fuzz-${{ matrix.target }}-artifacts + path: fuzz/artifacts/ diff --git a/Cargo.lock b/Cargo.lock index 02fe2e8..deb9817 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -378,7 +378,7 @@ checksum = "8543454e3c3f5126effff9cd44d562af4e31fb8ce1cc0d3dcd8f084515dbc1aa" dependencies = [ "cipher", "dbl", - "digest 0.10.7", + "digest", ] [[package]] @@ -652,18 +652,32 @@ dependencies = [ ] [[package]] -name = "curve25519-dalek-ng" -version = "4.1.1" +name = "curve25519-dalek" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ - "byteorder", - "digest 0.9.0", + "cfg-if", + "cpufeatures 0.2.17", + "curve25519-dalek-derive", + "fiat-crypto", "rand_core 0.6.4", - "subtle-ng", + "rustc_version", + "subtle", "zeroize", ] +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "dasp_sample" version = "0.11.0" @@ -705,15 +719,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - [[package]] name = "digest" version = "0.10.7" @@ -794,7 +799,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", - "digest 0.10.7", + "digest", "elliptic-curve", "rfc6979", "signature", @@ -815,7 +820,7 @@ checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint 0.5.5", - "digest 0.10.7", + "digest", "ff", "generic-array", "group", @@ -888,6 +893,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + [[package]] name = "find-msvc-tools" version = "0.1.14" @@ -1211,7 +1222,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.7", + "digest", ] [[package]] @@ -2704,7 +2715,7 @@ checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" dependencies = [ "cfg-if", "cpufeatures 0.2.17", - "digest 0.10.7", + "digest", ] [[package]] @@ -2715,7 +2726,7 @@ checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", "cpufeatures 0.2.17", - "digest 0.10.7", + "digest", ] [[package]] @@ -2749,7 +2760,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest 0.10.7", + "digest", "rand_core 0.6.4", ] @@ -2831,12 +2842,6 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" -[[package]] -name = "subtle-ng" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" - [[package]] name = "syn" version = "2.0.119" @@ -3270,6 +3275,14 @@ dependencies = [ "tsproto-types", ] +[[package]] +name = "tsc-model" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "tsclientlib" version = "0.2.0" @@ -3317,6 +3330,7 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", + "tsc-model", "tsclientlib", "tsproto-packets", ] @@ -3331,7 +3345,7 @@ dependencies = [ "clap", "criterion", "crypto-bigint 0.6.1", - "curve25519-dalek-ng", + "curve25519-dalek", "eax", "futures", "generic-array", @@ -3389,7 +3403,7 @@ version = "0.1.0" dependencies = [ "base64 0.22.1", "bitflags", - "curve25519-dalek-ng", + "curve25519-dalek", "elliptic-curve", "generic-array", "heck", diff --git a/Cargo.toml b/Cargo.toml index 6ccdb35..aaa44ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] resolver = "3" +exclude = ["fuzz"] members = [ "crates/proto/tsproto-types", "crates/proto/tsproto-structs", @@ -7,6 +8,7 @@ members = [ "crates/proto/tsproto", "crates/proto/ts-bookkeeping", "crates/proto/tsclientlib", + "crates/tsc-model", "tools/tsctl", ] default-members = [ @@ -16,6 +18,7 @@ default-members = [ "crates/proto/tsproto", "crates/proto/ts-bookkeeping", "crates/proto/tsclientlib", + "crates/tsc-model", "tools/tsctl", ] diff --git a/crates/proto/UPSTREAM.md b/crates/proto/UPSTREAM.md index 89e8963..2d89511 100644 --- a/crates/proto/UPSTREAM.md +++ b/crates/proto/UPSTREAM.md @@ -51,3 +51,12 @@ against or offered back to upstream. `notifystreamsignaling`, `notifystreamclientjoined`, `notifystreamclientleft`) and commands (`setupstream`, `stopstream`, `streamsignaling`, `respondjoinstreamrequest`, `removeclientfromstream`). See `docs/protocol-notes/ts6-streaming.md`. +5. **`curve25519-dalek-ng` → `curve25519-dalek` 4** (`tsproto-types`, `tsproto`). The `-ng` + fork is unmaintained; the API is the same apart from the basepoint table being a + reference. Verified by the license-chain unit tests and a live TeamSpeak 6 handshake. +6. **Panics on malformed input found by fuzzing** (`fuzz/`): + - `tsproto/src/license.rs`: an empty license (`initivexpand2 l=`) indexed `data[0]`; + license properties indexed past the end or with start > end. All property reads + are bounds-checked now. + - `tsproto-packets/src/packets.rs`: the invalid-codec error for short C2S audio + packets read `content[4]` instead of the codec byte `content[2]`. diff --git a/crates/proto/tsproto-packets/src/packets.rs b/crates/proto/tsproto-packets/src/packets.rs index 750d8fe..bc4c7a8 100644 --- a/crates/proto/tsproto-packets/src/packets.rs +++ b/crates/proto/tsproto-packets/src/packets.rs @@ -659,7 +659,7 @@ impl<'a> AudioData<'a> { Ok(AudioData::C2S { id, codec: CodecType::from_u8(content[2]) - .ok_or_else(|| Error::InvalidCodec(content[4]))?, + .ok_or_else(|| Error::InvalidCodec(content[2]))?, data: &content[3..], }) } @@ -679,7 +679,7 @@ impl<'a> AudioData<'a> { return Err(Error::PacketContentTooShort(content.len())); } let codec = - CodecType::from_u8(content[2]).ok_or_else(|| Error::InvalidCodec(content[4]))?; + CodecType::from_u8(content[2]).ok_or_else(|| Error::InvalidCodec(content[2]))?; if newprotocol { if content.len() < 14 { return Err(Error::PacketContentTooShort(content.len())); @@ -1187,6 +1187,14 @@ impl OutAudio { #[cfg(test)] mod tests { + #[test] + fn short_c2s_audio_with_invalid_codec_is_an_error() { + // Packet id + invalid codec byte, shorter than the old error path indexed. + for p_type in [PacketType::Voice, PacketType::VoiceWhisper] { + assert!(AudioData::parse(p_type, false, Direction::C2S, &[0, 1, 0xff]).is_err()); + } + } + use super::*; fn test_audio_roundtrip(dir: Direction, data: &AudioData) { diff --git a/crates/proto/tsproto-types/Cargo.toml b/crates/proto/tsproto-types/Cargo.toml index 08cec73..6be3ec5 100644 --- a/crates/proto/tsproto-types/Cargo.toml +++ b/crates/proto/tsproto-types/Cargo.toml @@ -20,7 +20,7 @@ include = [ [dependencies] base64 = "0.22" bitflags = { version = "2", features = ["serde"] } -curve25519-dalek-ng = "4" +curve25519-dalek = { version = "4", features = ["rand_core"] } elliptic-curve = { version = "0.13", features = ["ecdh"] } generic-array = "0.14" num-bigint = "0.4" diff --git a/crates/proto/tsproto-types/src/crypto.rs b/crates/proto/tsproto-types/src/crypto.rs index cc507a8..85affd1 100644 --- a/crates/proto/tsproto-types/src/crypto.rs +++ b/crates/proto/tsproto-types/src/crypto.rs @@ -3,9 +3,9 @@ use std::convert::TryInto; use std::{cmp, fmt, str}; use base64::prelude::*; -use curve25519_dalek_ng::constants; -use curve25519_dalek_ng::edwards::{CompressedEdwardsY, EdwardsPoint}; -use curve25519_dalek_ng::scalar::Scalar; +use curve25519_dalek::constants; +use curve25519_dalek::edwards::{CompressedEdwardsY, EdwardsPoint}; +use curve25519_dalek::scalar::Scalar; use elliptic_curve::sec1::{FromEncodedPoint, ToEncodedPoint}; use generic_array::GenericArray; use generic_array::typenum::Unsigned; @@ -522,7 +522,7 @@ impl EccKeyPrivEd25519 { impl<'a> From<&'a EccKeyPrivEd25519> for EccKeyPubEd25519 { fn from(priv_key: &'a EccKeyPrivEd25519) -> Self { - Self((&constants::ED25519_BASEPOINT_TABLE * &priv_key.0).compress()) + Self((constants::ED25519_BASEPOINT_TABLE * &priv_key.0).compress()) } } diff --git a/crates/proto/tsproto/Cargo.toml b/crates/proto/tsproto/Cargo.toml index d1f1332..588880b 100644 --- a/crates/proto/tsproto/Cargo.toml +++ b/crates/proto/tsproto/Cargo.toml @@ -21,7 +21,7 @@ include = [ aes = "0.8" base64 = "0.22" omnom = "3" -curve25519-dalek-ng = "4" +curve25519-dalek = { version = "4", features = ["rand_core"] } eax = "0.5" futures = "0.3" generic-array = "0.14" diff --git a/crates/proto/tsproto/examples/test-ed25519.rs b/crates/proto/tsproto/examples/test-ed25519.rs index 655e0c9..4f47a7a 100644 --- a/crates/proto/tsproto/examples/test-ed25519.rs +++ b/crates/proto/tsproto/examples/test-ed25519.rs @@ -1,7 +1,7 @@ use base64::prelude::*; use clap::Parser; -use curve25519_dalek_ng::edwards::CompressedEdwardsY; -use curve25519_dalek_ng::scalar::Scalar; +use curve25519_dalek::edwards::CompressedEdwardsY; +use curve25519_dalek::scalar::Scalar; #[derive(Parser, Debug)] #[command(author, about)] diff --git a/crates/proto/tsproto/src/algorithms.rs b/crates/proto/tsproto/src/algorithms.rs index 00eb0da..1e5fbf0 100644 --- a/crates/proto/tsproto/src/algorithms.rs +++ b/crates/proto/tsproto/src/algorithms.rs @@ -1,5 +1,5 @@ //! Handle packet splitting and cryptography -use curve25519_dalek_ng::edwards::EdwardsPoint; +use curve25519_dalek::edwards::EdwardsPoint; use eax::aead::consts::{U16, U8}; use eax::{AeadInPlace, Eax, KeyInit}; use generic_array::GenericArray; diff --git a/crates/proto/tsproto/src/license.rs b/crates/proto/tsproto/src/license.rs index ad40c7e..b0084a9 100644 --- a/crates/proto/tsproto/src/license.rs +++ b/crates/proto/tsproto/src/license.rs @@ -3,8 +3,8 @@ use std::fmt; use std::io::Cursor; use std::str; -use curve25519_dalek_ng::edwards::EdwardsPoint; -use curve25519_dalek_ng::scalar::Scalar; +use curve25519_dalek::edwards::EdwardsPoint; +use curve25519_dalek::scalar::Scalar; use num_derive::{FromPrimitive, ToPrimitive}; use num_traits::{FromPrimitive as _, ToPrimitive as _}; use omnom::{ReadExt, WriteExt}; @@ -165,7 +165,9 @@ impl Licenses { pub fn parse(data: Vec) -> Result { Self::parse_internal(data, true) } pub fn parse_internal(data: Vec, check_expired: bool) -> Result { - let version = data[0]; + let Some(&version) = data.first() else { + return Err(Error::TooShort(0, "empty license")); + }; if version != 0 && version != 1 { return Err(Error::UnsupportedVersion(version)); } @@ -510,17 +512,20 @@ impl License { ) -> Result>> + 'b> { if let InnerLicense::Ts5Server { properties } = &self.inner { Ok(properties.iter().map(move |p| { + // Every access is bounds-checked: the data comes from the server. + let get = |start: usize, end: usize| { + data.get(start..end).ok_or(Error::TooShort(data.len(), "license property")) + }; let o = BLOCK_MIN_LEN + 2 + p; - let len = data[o]; + let header = get(o, o + 3)?; + let (len, id, typ) = (header[0], header[1], header[2]); let len_usize = len as usize; - let id = data[o + 1]; - let typ = data[o + 2]; // Check length if let Some(expected) = match typ { // String, check that it is null-terminated 0 => { - if data[o + len_usize] != 0 { + if get(o + len_usize, o + len_usize + 1)?[0] != 0 { return Err(Error::NonterminatedString); } None @@ -540,14 +545,14 @@ impl License { return Err(Error::WrongPropertyType { id, expected: 1, actual: typ }); } Ok(LicenseProperty::Unknown1( - (&data[o + 3..o + 3 + 4]).read_be().map_err(Error::Deserialize)?, + get(o + 3, o + 3 + 4)?.read_be().map_err(Error::Deserialize)?, )) } 2 => { if typ != 0 { return Err(Error::WrongPropertyType { id, expected: 0, actual: typ }); } - let s = str::from_utf8(&data[o + 3..o + len_usize]) + let s = str::from_utf8(get(o + 3, o + len_usize)?) .map_err(Error::DeserializeString)?; Ok(LicenseProperty::Issuer(s)) } @@ -556,12 +561,10 @@ impl License { return Err(Error::WrongPropertyType { id, expected: 1, actual: typ }); } Ok(LicenseProperty::MaxClients( - (&data[o + 3..o + 3 + 4]).read_be().map_err(Error::Deserialize)?, + get(o + 3, o + 3 + 4)?.read_be().map_err(Error::Deserialize)?, )) } - _ => { - Ok(LicenseProperty::Unknown { id, typ, data: &data[o + 3..o + len_usize] }) - } + _ => Ok(LicenseProperty::Unknown { id, typ, data: get(o + 3, o + len_usize)? }), } })) } else { @@ -844,6 +847,11 @@ impl LicenseBlockBuilder<'_, '_> { #[cfg(test)] mod tests { + #[test] + fn empty_license_is_an_error() { + assert!(super::Licenses::parse(Vec::new()).is_err()); + } + use super::*; use base64::prelude::*; diff --git a/crates/tsc-model/Cargo.toml b/crates/tsc-model/Cargo.toml new file mode 100644 index 0000000..f4bda65 --- /dev/null +++ b/crates/tsc-model/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "tsc-model" +version = "0.1.0" +description = "UI-facing domain model shared by the client engine, gateway and UI (no IO)." +edition.workspace = true +rust-version.workspace = true +license.workspace = true +repository.workspace = true +publish.workspace = true + +[dependencies] +serde = { version = "1", features = ["derive"] } + +[dev-dependencies] +serde_json = "1" + +[lints] +workspace = true diff --git a/crates/tsc-model/src/lib.rs b/crates/tsc-model/src/lib.rs new file mode 100644 index 0000000..350e491 --- /dev/null +++ b/crates/tsc-model/src/lib.rs @@ -0,0 +1,8 @@ +//! Domain model shared by the client engine, the gateway and the UI. +//! +//! Nothing in here does IO; the types describe what a server offers and what +//! the user sees. + +mod server; + +pub use server::{Capabilities, ServerFlavor, ServerVersion}; diff --git a/crates/tsc-model/src/server.rs b/crates/tsc-model/src/server.rs new file mode 100644 index 0000000..d13e763 --- /dev/null +++ b/crates/tsc-model/src/server.rs @@ -0,0 +1,138 @@ +//! Server software detection and the capabilities that follow from it. + +use std::fmt; + +use serde::{Deserialize, Serialize}; + +/// Parsed `virtualserver_version`, e.g. `3.13.8 [Build: 1779874471]` or +/// `6.0.0-beta13.1 [Build: 1790080330]`. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +pub struct ServerVersion { + pub major: u32, + pub minor: u32, + pub patch: u32, + /// Pre-release tag such as `beta13.1`. + pub pre: Option, + /// Build timestamp (seconds since the Unix epoch). + pub build: Option, +} + +impl ServerVersion { + pub fn parse(s: &str) -> Option { + let s = s.trim(); + let (version, rest) = s.split_once(' ').unwrap_or((s, "")); + let build = rest + .trim() + .strip_prefix("[Build:") + .and_then(|b| b.strip_suffix(']')) + .and_then(|b| b.trim().parse().ok()); + let (numbers, pre) = match version.split_once('-') { + Some((n, p)) => (n, Some(p.to_string())), + None => (version, None), + }; + let mut parts = numbers.split('.').map(|p| p.parse::()); + let major = parts.next()?.ok()?; + let minor = parts.next().unwrap_or(Ok(0)).ok()?; + let patch = parts.next().unwrap_or(Ok(0)).ok()?; + Some(Self { major, minor, patch, pre, build }) + } +} + +impl fmt::Display for ServerVersion { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}.{}.{}", self.major, self.minor, self.patch)?; + if let Some(pre) = &self.pre { + write!(f, "-{pre}")?; + } + Ok(()) + } +} + +/// Which server software we are talking to. +#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum ServerFlavor { + /// TeamSpeak 3 server (3.x). + Ts3(ServerVersion), + /// TeamSpeak 6 server (6.x; TeamSpeak 5 server betas are treated alike). + Ts6(ServerVersion), + /// Unparseable or unexpected version string. + Unknown(String), +} + +impl ServerFlavor { + /// Classify a `virtualserver_version` string. + pub fn from_version_string(s: &str) -> Self { + match ServerVersion::parse(s) { + Some(v) if v.major == 3 => ServerFlavor::Ts3(v), + Some(v) if v.major >= 5 => ServerFlavor::Ts6(v), + _ => ServerFlavor::Unknown(s.to_string()), + } + } + + pub fn version(&self) -> Option<&ServerVersion> { + match self { + ServerFlavor::Ts3(v) | ServerFlavor::Ts6(v) => Some(v), + ServerFlavor::Unknown(_) => None, + } + } + + pub fn capabilities(&self) -> Capabilities { + match self { + ServerFlavor::Ts3(_) => { + Capabilities { streams: false, raw_query: true, ssh_query: true, http_query: false } + } + ServerFlavor::Ts6(_) => { + Capabilities { streams: true, raw_query: false, ssh_query: true, http_query: true } + } + ServerFlavor::Unknown(_) => Capabilities::default(), + } + } +} + +/// Features that depend on the server software. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub struct Capabilities { + /// Screen sharing / video streams (TeamSpeak 6). + pub streams: bool, + /// Raw TCP ServerQuery (TeamSpeak 3 only; may still be disabled by the admin). + pub raw_query: bool, + /// SSH ServerQuery. + pub ssh_query: bool, + /// HTTP WebQuery (TeamSpeak 6), request/response only, no events. + pub http_query: bool, +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parses_ts3() { + let v = ServerVersion::parse("3.13.8 [Build: 1779874471]").unwrap(); + assert_eq!((v.major, v.minor, v.patch), (3, 13, 8)); + assert_eq!(v.pre, None); + assert_eq!(v.build, Some(1_779_874_471)); + let flavor = ServerFlavor::from_version_string("3.13.8 [Build: 1779874471]"); + assert!(matches!(flavor, ServerFlavor::Ts3(_))); + assert!(!flavor.capabilities().streams); + } + + #[test] + fn parses_ts6_beta() { + let s = "6.0.0-beta13.1 [Build: 1790080330]"; + let v = ServerVersion::parse(s).unwrap(); + assert_eq!(v.pre.as_deref(), Some("beta13.1")); + assert_eq!(v.to_string(), "6.0.0-beta13.1"); + let flavor = ServerFlavor::from_version_string(s); + assert!(matches!(flavor, ServerFlavor::Ts6(_))); + assert!(flavor.capabilities().streams); + assert!(!flavor.capabilities().raw_query); + } + + #[test] + fn handles_garbage() { + assert!(matches!(ServerFlavor::from_version_string(""), ServerFlavor::Unknown(_))); + assert!(matches!(ServerFlavor::from_version_string("x.y"), ServerFlavor::Unknown(_))); + assert_eq!(ServerVersion::parse("3").unwrap().minor, 0); + } +} diff --git a/fuzz/.gitignore b/fuzz/.gitignore new file mode 100644 index 0000000..fe68c97 --- /dev/null +++ b/fuzz/.gitignore @@ -0,0 +1,4 @@ +target/ +corpus/ +artifacts/ +coverage/ diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock new file mode 100644 index 0000000..226c4d9 --- /dev/null +++ b/fuzz/Cargo.lock @@ -0,0 +1,1431 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array", +] + +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures 0.2.17", +] + +[[package]] +name = "arbitrary" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" +dependencies = [ + "serde_core", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "207aedd8d29a0eb804986bc99eed0d43719fec84a9b7f9c8b70cf83b97cffcc1" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "chacha20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.1", + "rand_core 0.10.1", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + +[[package]] +name = "cmac" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8543454e3c3f5126effff9cd44d562af4e31fb8ce1cc0d3dcd8f084515dbc1aa" +dependencies = [ + "cipher", + "dbl", + "digest", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-bigint" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96272c2ff28b807e09250b180ad1fb7889a3258f7455759b5c3c58b719467130" +dependencies = [ + "num-traits", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "typenum", +] + +[[package]] +name = "csv" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52cd9d68cf7efc6ddfaaee42e7288d3a99d613d4b50f76ce9827ae0c6e14f938" +dependencies = [ + "csv-core", + "itoa", + "ryu", + "serde_core", +] + +[[package]] +name = "csv-core" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "704a3c26996a80471189265814dbc2c257598b96b8a7feae2d31ace646bb9782" +dependencies = [ + "memchr", +] + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "curve25519-dalek-derive", + "fiat-crypto", + "rand_core 0.6.4", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "dbl" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd2735a791158376708f9347fe8faba9667589d82427ef3aed6794a8981de3d9" +dependencies = [ + "generic-array", +] + +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" +dependencies = [ + "serde_core", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "eax" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9954fabd903b82b9d7a68f65f97dc96dd9ad368e40ccc907a7c19d53e6bfac28" +dependencies = [ + "aead", + "cipher", + "cmac", + "ctr", + "subtle", +] + +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest", + "elliptic-curve", + "rfc6979", + "signature", + "spki", +] + +[[package]] +name = "either" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34" + +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint 0.5.5", + "digest", + "ff", + "generic-array", + "group", + "hkdf", + "pem-rfc7468", + "pkcs8", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "ff" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + +[[package]] +name = "find-msvc-tools" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484" + +[[package]] +name = "futures" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-executor" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", + "zeroize", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "rand_core 0.10.1", +] + +[[package]] +name = "git-testament" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a74999c921479f919c87a9d2e6922a79a18683f18105344df8e067149232e51" +dependencies = [ + "git-testament-derive", +] + +[[package]] +name = "git-testament-derive" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbeac967e71eb3dc1656742fc7521ec7cd3b6b88738face65bf1fddf702bc4c0" +dependencies = [ + "log", + "proc-macro2", + "quote", + "syn 2.0.119", + "time", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "inout" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +dependencies = [ + "generic-array", +] + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom 0.4.3", + "libc", +] + +[[package]] +name = "libc" +version = "0.2.189" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" + +[[package]] +name = "libfuzzer-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9fd2f41a1cba099f79a0b6b6c35656cf7c03351a7bae8ff0f28f25270f929d2" +dependencies = [ + "arbitrary", + "cc", +] + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "mio" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b18443e9c262bfe8fa82f51666e2642c53393f7e5c27b3e1aeab922cff5b9d8" +dependencies = [ + "libc", + "wasi", + "windows-sys", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-bigint" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "omnom" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66562a92c66d5937e9d549597c2d3cafe3d2367dd08dc257da730587c2cfc218" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2", +] + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quicklz" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "750eab265a26a0cd064f2a2b222bf172cc06d7a873e113e5f6d0118cc6e5fbb1" +dependencies = [ + "bit-vec", + "byteorder", + "thiserror 1.0.69", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" +dependencies = [ + "libc", + "rand_chacha", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" +dependencies = [ + "chacha20", + "getrandom 0.4.3", + "rand_core 0.10.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "ref-cast" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e440fb4e4b4147295338efb76001ab9e4efc0e5839df2c47fc5ac2381d365c3" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "self_cell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab42ca02749e120097e328d91d415325bdf43b1c72c4c8badf37375fe40a813" + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "serde_spanned" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26" +dependencies = [ + "serde_core", +] + +[[package]] +name = "sha-1" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "digest", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core 0.6.4", +] + +[[package]] +name = "simple_asn1" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d585997b0ac10be3c5ee635f1bab02d512760d14b7c468801ac8a01d9ae5f1d" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror 2.0.21", + "time", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "socket2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "t4rust-derive" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e411692d6e0c8ce07f65a8210e95dcfb56cc4600940456592a49a3579ef6396" +dependencies = [ + "nom", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl 2.0.21", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "time" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" + +[[package]] +name = "time-macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tokio" +version = "1.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" +dependencies = [ + "libc", + "mio", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys", +] + +[[package]] +name = "tokio-macros" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "toml" +version = "1.1.6+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "920602543f0911ab71da12c50d59701da54c196d1a2bf5cb4b75667f137a406a" +dependencies = [ + "indexmap", + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "1.1.1+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_parser" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" +dependencies = [ + "winnow", +] + +[[package]] +name = "toml_writer" +version = "1.1.2+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "ts-bookkeeping" +version = "0.1.0" +dependencies = [ + "base64", + "heck", + "itertools", + "num-derive", + "num-traits", + "serde", + "t4rust-derive", + "thiserror 2.0.21", + "time", + "tracing", + "tsproto-packets", + "tsproto-structs", + "tsproto-types", +] + +[[package]] +name = "tsc-fuzz" +version = "0.0.0" +dependencies = [ + "libfuzzer-sys", + "ts-bookkeeping", + "tsproto", + "tsproto-packets", +] + +[[package]] +name = "tsproto" +version = "0.2.0" +dependencies = [ + "aes", + "base64", + "crypto-bigint 0.6.1", + "curve25519-dalek", + "eax", + "futures", + "generic-array", + "git-testament", + "num-bigint", + "num-derive", + "num-traits", + "omnom", + "pin-project-lite", + "quicklz", + "rand 0.10.3", + "serde", + "sha-1", + "sha2", + "thiserror 2.0.21", + "time", + "tokio", + "tracing", + "tsproto-packets", + "tsproto-types", +] + +[[package]] +name = "tsproto-packets" +version = "0.1.0" +dependencies = [ + "base64", + "bitflags", + "num-derive", + "num-traits", + "omnom", + "self_cell", + "serde", + "thiserror 2.0.21", +] + +[[package]] +name = "tsproto-structs" +version = "0.2.0" +dependencies = [ + "base64", + "csv", + "heck", + "once_cell", + "serde", + "toml", +] + +[[package]] +name = "tsproto-types" +version = "0.1.0" +dependencies = [ + "base64", + "bitflags", + "curve25519-dalek", + "elliptic-curve", + "generic-array", + "heck", + "num-bigint", + "num-derive", + "num-traits", + "p256", + "rand 0.8.8", + "ref-cast", + "serde", + "sha-1", + "simple_asn1", + "t4rust-derive", + "thiserror 2.0.21", + "time", + "tsproto-structs", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "unicode-ident" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "winnow" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" + +[[package]] +name = "zerocopy" +version = "0.8.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17e8fafad82b542ff3717217ecdc736231b59e387768c9630123b4ce4d2db44" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595f56e044df4f46a0c9a626f65c3d99eb8488f7e8a8baa12dd76326d9710bf2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zeroize" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml new file mode 100644 index 0000000..ed88ccc --- /dev/null +++ b/fuzz/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "tsc-fuzz" +version = "0.0.0" +publish = false +edition = "2024" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.4" +ts-bookkeeping = { path = "../crates/proto/ts-bookkeeping" } +tsproto = { path = "../crates/proto/tsproto" } +tsproto-packets = { path = "../crates/proto/tsproto-packets" } + +# Not part of the main workspace: cargo-fuzz needs a nightly toolchain. +[workspace] + +[[bin]] +name = "packet" +path = "fuzz_targets/packet.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "command" +path = "fuzz_targets/command.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "license" +path = "fuzz_targets/license.rs" +test = false +doc = false +bench = false diff --git a/fuzz/fuzz_targets/command.rs b/fuzz/fuzz_targets/command.rs new file mode 100644 index 0000000..9dc4177 --- /dev/null +++ b/fuzz/fuzz_targets/command.rs @@ -0,0 +1,24 @@ +//! Decrypted command payloads, parsed into typed messages. +#![no_main] + +use libfuzzer_sys::fuzz_target; +use ts_bookkeeping::messages::s2c::InMessage; +use tsproto_packets::commands::CommandParser; +use tsproto_packets::packets::{Direction, InPacket}; + +/// S2C header: 8 byte MAC, packet id 1, type Command with the NewProtocol flag. +const HEADER: [u8; 11] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0x22]; + +fuzz_target!(|data: &[u8]| { + let (_, args) = CommandParser::new(data); + for arg in args { + let _ = format!("{arg:?}"); + } + + let mut packet = HEADER.to_vec(); + packet.extend_from_slice(data); + let packet = InPacket::new(Direction::S2C, &packet); + if let Ok(msg) = InMessage::new(&packet.header(), data) { + let _ = format!("{msg:?}"); + } +}); diff --git a/fuzz/fuzz_targets/license.rs b/fuzz/fuzz_targets/license.rs new file mode 100644 index 0000000..2ecc5b1 --- /dev/null +++ b/fuzz/fuzz_targets/license.rs @@ -0,0 +1,11 @@ +//! The license chain sent in `initivexpand2 l=...` during the handshake. +#![no_main] + +use libfuzzer_sys::fuzz_target; +use tsproto::license::Licenses; + +fuzz_target!(|data: &[u8]| { + if let Ok(licenses) = Licenses::parse_ignore_expired(data.to_vec()) { + let _ = format!("{licenses:?}"); + } +}); diff --git a/fuzz/fuzz_targets/packet.rs b/fuzz/fuzz_targets/packet.rs new file mode 100644 index 0000000..c2a5430 --- /dev/null +++ b/fuzz/fuzz_targets/packet.rs @@ -0,0 +1,15 @@ +//! Raw UDP packets from the server. +#![no_main] + +use libfuzzer_sys::fuzz_target; +use tsproto_packets::packets::{Direction, InPacket}; + +fuzz_target!(|data: &[u8]| { + for dir in [Direction::S2C, Direction::C2S] { + if let Ok(packet) = InPacket::try_new(dir, data) { + let _ = format!("{packet:?}"); + let _ = packet.header().packet_type(); + let _ = packet.ack_packet(); + } + } +}); diff --git a/scripts/own-crates.sh b/scripts/own-crates.sh new file mode 100755 index 0000000..c66d8ce --- /dev/null +++ b/scripts/own-crates.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# Print `-p ` for every workspace crate outside the vendored crates/proto, +# for commands that apply strict checks to our own code only: +# cargo clippy $(scripts/own-crates.sh) --all-targets --no-deps -- -D warnings +set -euo pipefail +cd "$(dirname "$0")/.." +cargo metadata --no-deps --format-version 1 | + jq -r '.packages[] | select(.manifest_path | contains("/crates/proto/") | not) | "-p \(.name)"' | + tr '\n' ' ' diff --git a/tools/tsctl/Cargo.toml b/tools/tsctl/Cargo.toml index 40ed031..bf0650b 100644 --- a/tools/tsctl/Cargo.toml +++ b/tools/tsctl/Cargo.toml @@ -20,6 +20,7 @@ tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } tsclientlib = { path = "../../crates/proto/tsclientlib" } tsproto-packets = { path = "../../crates/proto/tsproto-packets" } +tsc-model = { path = "../../crates/tsc-model" } [lints] workspace = true diff --git a/tools/tsctl/src/tree.rs b/tools/tsctl/src/tree.rs index 92680c4..22019f3 100644 --- a/tools/tsctl/src/tree.rs +++ b/tools/tsctl/src/tree.rs @@ -4,6 +4,7 @@ use std::collections::HashMap; use std::fmt::Write; use tsclientlib::data; +use tsc_model::ServerFlavor; use tsclientlib::{ChannelId, ClientType}; /// Minimal channel view, so the ordering logic can be tested without a connection. @@ -114,7 +115,12 @@ pub fn from_state(state: &data::Connection) -> String { streaming: c.is_streaming == Some(true), }) .collect(); - render(&state.server.name, &channels, &clients) + let flavor = match ServerFlavor::from_version_string(&state.server.version) { + ServerFlavor::Ts3(v) => format!("TeamSpeak 3 {v}"), + ServerFlavor::Ts6(v) => format!("TeamSpeak 6 {v}"), + ServerFlavor::Unknown(v) => format!("unknown version {v:?}"), + }; + render(&format!("{} ({flavor})", state.server.name), &channels, &clients) } #[cfg(test)]