diff --git a/rust/src/smb/smb1_records.rs b/rust/src/smb/smb1_records.rs index 4ba8a6a06e..c5ca183621 100644 --- a/rust/src/smb/smb1_records.rs +++ b/rust/src/smb/smb1_records.rs @@ -198,10 +198,12 @@ pub struct Smb1NegotiateProtocolRecord<'a> { pub fn parse_smb1_negotiate_protocol_record(i: &[u8]) -> IResult<&[u8], Smb1NegotiateProtocolRecord<'_>> { - let (i, _wtc) = le_u8(i)?; - let (i, _bcc) = le_u16(i)?; + let (i, _wct) = le_u8(i)?; + let (i, bcc) = le_u16(i)?; // dialects is a list of [1 byte buffer format][string][0 terminator] - let (i, dialects) = many1(complete(take_until_and_consume(b"\0")))(i)?; + // honour ByteCount to avoid unbounded allocation + let (i, payload) = take(bcc as usize)(i)?; + let (_, dialects) = many1(complete(take_until_and_consume(b"\0")))(payload)?; let record = Smb1NegotiateProtocolRecord { dialects }; Ok((i, record)) }