From 2884811a77863e8ccf8eba8d40a344f2c0287883 Mon Sep 17 00:00:00 2001 From: nothendev Date: Wed, 18 Oct 2023 21:08:03 +0300 Subject: [PATCH] wtf --- protocol/src/ser.rs | 1 - protocol/src/ser/types.rs | 12 +++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) 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");