From: Sascha Steinbiss Date: Fri, 9 Jun 2023 09:12:02 +0000 (+0200) Subject: rfb: be more strict parsing the version X-Git-Tag: suricata-7.0.0~100 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd1fbf392e04e0bfc4b8f7e680636ddee0a47c60;p=thirdparty%2Fsuricata.git rfb: be more strict parsing the version --- diff --git a/rust/src/rfb/parser.rs b/rust/src/rfb/parser.rs index 0fba65333a..bdbc1b7e73 100644 --- a/rust/src/rfb/parser.rs +++ b/rust/src/rfb/parser.rs @@ -18,6 +18,7 @@ // Author: Frank Honza use nom7::bytes::streaming::take; +use nom7::bytes::streaming::tag; use nom7::combinator::map_res; use nom7::number::streaming::*; use nom7::*; @@ -115,12 +116,11 @@ pub struct ServerInit { } pub fn parse_protocol_version(i: &[u8]) -> IResult<&[u8], ProtocolVersion> { - let (i, _rfb_string) = map_res(take(3_usize), str::from_utf8)(i)?; - let (i, _) = be_u8(i)?; + let (i, _) = tag("RFB ")(i)?; let (i, major) = map_res(take(3_usize), str::from_utf8)(i)?; - let (i, _) = be_u8(i)?; + let (i, _) = tag(".")(i)?; let (i, minor) = map_res(take(3_usize), str::from_utf8)(i)?; - let (i, _) = be_u8(i)?; + let (i, _) = tag("\n")(i)?; Ok(( i, ProtocolVersion {