diff --git a/protocol/src/ser.rs b/protocol/src/ser.rs index 24a3a50..63425a0 100644 --- a/protocol/src/ser.rs +++ b/protocol/src/ser.rs @@ -22,7 +22,6 @@ use ::bytes::{BufMut, Bytes, BytesMut}; pub use aott::prelude::parser; pub use aott::prelude::Parser; use aott::{error::FundamentalError, iter::IterParser, prelude::*}; -use tracing::debug; mod error; mod types; diff --git a/protocol/src/ser/types.rs b/protocol/src/ser/types.rs index 965c5c9..8ea3e27 100644 --- a/protocol/src/ser/types.rs +++ b/protocol/src/ser/types.rs @@ -34,10 +34,16 @@ impl Deserialize for FixedStr { .map(|VarInt(x)| x) .filter(|x| *x >= 0, |x| Label::String(StringError::LengthOOB(x))) .map(|x| x as usize) + .filter( + |x| *x <= N, + |x| { + Label::String(StringError::FixedLengthBigger { + expected: N, + actual: x, + }) + }, + ) .parse_with(input)?; - debug!(%length, expected_length=%N, "[fixedstr] checking length"); - let length = length as usize; - assert!(length <= N); let string = std::str::from_utf8(input.input.slice((input.offset)..(input.offset + length))) .expect("invalid utf8. that's a skill issue ngl");