From: Jason Ish Date: Tue, 4 Aug 2020 19:50:26 +0000 (-0600) Subject: dns: add tailing data to split tcp unit test X-Git-Tag: suricata-6.0.0-beta1~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6cff558663f1d9c85ecd9cd15f0a8742856afa83;p=thirdparty%2Fsuricata.git dns: add tailing data to split tcp unit test Add trailing data to the complete payload to test the case where data is consumed, but still incomplete. --- diff --git a/rust/src/dns/dns.rs b/rust/src/dns/dns.rs index cea820a731..fda3a6b8c3 100644 --- a/rust/src/dns/dns.rs +++ b/rust/src/dns/dns.rs @@ -1460,21 +1460,38 @@ mod tests { 0x00, 0x1c, 0x10, 0x32, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]; - /* complete payload */ + /* complete payload plus the start of a new payload */ let buf2: &[u8] = &[ 0x00, 0x1c, 0x10, 0x32, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x67, 0x6F, 0x6F, 0x67, 0x6C, 0x65, 0x03, - 0x63, 0x6F, 0x6D, 0x00, 0x00, 0x10, 0x00, 0x01 + 0x63, 0x6F, 0x6D, 0x00, 0x00, 0x10, 0x00, 0x01, + + // next. + 0x00, 0x1c, 0x10, 0x32, 0x01, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ]; + + /* and the complete payload again with no trailing data. */ + let buf3: &[u8] = &[ + 0x00, 0x1c, 0x10, 0x32, 0x01, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x67, 0x6F, 0x6F, 0x67, 0x6C, 0x65, 0x03, + 0x63, 0x6F, 0x6D, 0x00, 0x00, 0x10, 0x00, 0x01, + ]; + let mut state = DNSState::new(); assert_eq!( AppLayerResult::incomplete(0, 30), state.parse_request_tcp(buf1) ); assert_eq!( - AppLayerResult::ok(), + AppLayerResult::incomplete(30, 30), state.parse_request_tcp(buf2) ); + assert_eq!( + AppLayerResult::ok(), + state.parse_request_tcp(buf3) + ); } }