]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
dns: add tailing data to split tcp unit test
authorJason Ish <jason.ish@oisf.net>
Tue, 4 Aug 2020 19:50:26 +0000 (13:50 -0600)
committerJason Ish <jason.ish@oisf.net>
Tue, 4 Aug 2020 19:58:08 +0000 (13:58 -0600)
Add trailing data to the complete payload to test the case
where data is consumed, but still incomplete.

rust/src/dns/dns.rs

index cea820a73121455638476a801ae67130a7b23402..fda3a6b8c31900c5b6c51e25bc806af643b96ce2 100644 (file)
@@ -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)
+        );
     }
 }