From 9f4332c20c3f6e0b61a15737b5bac0301e91f9a1 Mon Sep 17 00:00:00 2001 From: Linus Probert Date: Tue, 26 May 2026 21:52:58 +0200 Subject: [PATCH] Fixes a fuzzing error based on the latest fix The compat check was getting in the way after the latest buggfix. So the compat has now been completely removed. There is no real value in comparing against the OG implementation after this diverge. Signed-off-by: Linus Probert --- Cargo.lock | 14 +++++--------- compat/Cargo.lock | 10 ---------- compat/Cargo.toml | 1 - compat/src/lib.rs | 48 ++--------------------------------------------- fuzz/Cargo.toml | 2 -- 5 files changed, 7 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 219eb7c..1c82248 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,7 +36,6 @@ dependencies = [ "arbitrary", "bencher", "libmudtelnet", - "libtelnet-rs", "rand", ] @@ -77,14 +76,6 @@ dependencies = [ "compat", ] -[[package]] -name = "libtelnet-rs" -version = "2.0.0" -source = "git+https://github.com/cpu/libtelnet-rs?branch=cpu-libmudtelnet-compat#9e66f6336711503bd30fec1459c0087d1951b48e" -dependencies = [ - "bytes", -] - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -161,3 +152,8 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[patch.unused]] +name = "libtelnet-rs" +version = "2.0.0" +source = "git+https://github.com/cpu/libtelnet-rs?branch=cpu-libmudtelnet-compat#9e66f6336711503bd30fec1459c0087d1951b48e" diff --git a/compat/Cargo.lock b/compat/Cargo.lock index 59c4299..b23f809 100644 --- a/compat/Cargo.lock +++ b/compat/Cargo.lock @@ -36,7 +36,6 @@ dependencies = [ "arbitrary", "bencher", "libmudtelnet", - "libtelnet-rs", "rand", ] @@ -76,15 +75,6 @@ dependencies = [ "bytes", ] -[[package]] -name = "libtelnet-rs" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b91f14f906b14bbd9c2a4c6a81d6f01b825438de64adb3b15c8fcc223de25a1" -dependencies = [ - "bytes", -] - [[package]] name = "ppv-lite86" version = "0.2.17" diff --git a/compat/Cargo.toml b/compat/Cargo.toml index 99d8e0f..c8c3474 100644 --- a/compat/Cargo.toml +++ b/compat/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] arbitrary = { version = "1", optional = true, features = ["derive"] } -libtelnet-rs = "2.0.0" libmudtelnet = { path = "..", features = ["arbitrary"] } bencher = "0.1.5" rand = "0.8.5" diff --git a/compat/src/lib.rs b/compat/src/lib.rs index cd680c4..c584708 100644 --- a/compat/src/lib.rs +++ b/compat/src/lib.rs @@ -1,11 +1,6 @@ use libmudtelnet::compatibility::CompatibilityTable; -use libmudtelnet::events::{TelnetEvents, TelnetIAC, TelnetNegotiation, TelnetSubnegotiation}; use libmudtelnet::Parser; -use libtelnet_rs::compatibility::CompatibilityTable as OgCompatibilityTable; -use libtelnet_rs::events::TelnetEvents as OgTelnetEvents; -use libtelnet_rs::Parser as OgParser; - #[derive(Debug, Clone, Eq, PartialEq)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub struct TelnetApplication { @@ -15,52 +10,13 @@ pub struct TelnetApplication { pub fn test_app(app: &TelnetApplication) { let mut parser = Parser::with_support(CompatibilityTable::from_options(&app.options)); - let mut og_parser = OgParser::with_support(OgCompatibilityTable::from_options(&app.options)); - for data in &app.received_data { - let our_events = parser.receive(&data); - let og_events = events(og_parser.receive(&data)); - assert_eq!(our_events, og_events); - } - - for i in 0..255 { - assert_eq!( - parser.options.get_option(i).into_u8(), - og_parser.options.get_option(i).into_u8() - ); - } -} - -pub fn events(events: Vec) -> Vec { - events.into_iter().map(event).collect() -} - -pub fn event(event: OgTelnetEvents) -> TelnetEvents { - match event { - OgTelnetEvents::IAC(iac) => TelnetEvents::IAC(TelnetIAC::new(iac.command)), - OgTelnetEvents::Negotiation(neg) => { - TelnetEvents::Negotiation(TelnetNegotiation::new(neg.command, neg.option)) - } - OgTelnetEvents::Subnegotiation(sub) => { - TelnetEvents::Subnegotiation(TelnetSubnegotiation::new(sub.option, sub.buffer)) - } - OgTelnetEvents::DataReceive(data) => TelnetEvents::DataReceive(data), - OgTelnetEvents::DataSend(data) => TelnetEvents::DataSend(data), - OgTelnetEvents::DecompressImmediate(data) => TelnetEvents::DecompressImmediate(data), + parser.receive(data); } } pub fn test_escape(data: Vec) { - // For any input if we escape it, and then unescape it, we should get back the original data. let escaped = Parser::escape_iac(data.clone()); - let unescaped = Parser::unescape_iac(escaped.clone()); + let unescaped = Parser::unescape_iac(escaped); assert_eq!(data, unescaped); - - // The same should be true for the original implementation. - let og_escaped = OgParser::escape_iac(data.clone()); - let og_unescaped = OgParser::unescape_iac(og_escaped.clone()); - assert_eq!(data, og_unescaped); - - // And we expect the new and old implementation produce the same escaped output. - assert_eq!(escaped, og_escaped); } diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 62507d9..865431b 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -33,6 +33,4 @@ path = "parser/escape.rs" test = false doc = false -[patch.crates-io] -libtelnet-rs = { git = "https://github.com/cpu/libtelnet-rs", branch = "cpu-libmudtelnet-compat" }