]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/rpc: add partial data test
authorVictor Julien <victor@inliniac.net>
Thu, 6 Feb 2020 10:43:55 +0000 (10:43 +0000)
committerVictor Julien <victor@inliniac.net>
Thu, 6 Feb 2020 10:43:55 +0000 (10:43 +0000)
rust/src/nfs/rpc_records.rs

index 446935a0ba671dbbfb1ad87128f390205ccff177..723c73e55d1e1710f2c73e0c3d880dc2f1358d8c 100644 (file)
@@ -359,3 +359,23 @@ named!(pub parse_rpc_udp_reply<RpcReplyPacket>,
            }
    ))
 );
+
+#[cfg(test)]
+mod tests {
+    use crate::nfs::rpc_records::*;
+    use nom::Err::Incomplete;
+    use nom::Needed::Size;
+
+    #[test]
+    fn test_parse_input_too_short() {
+        let buf: &[u8] = &[
+            0x80, 0x0, 0x0, 0x9c, 0x8e, 0x28, 0x2, 0x7e
+        ];
+        let r = parse_rpc_request_partial(buf);
+        match r {
+            Err(Incomplete(e)) => { assert_eq!(e, Size(4)); },
+             _ => { panic!("failed {:?}",r); }
+       }
+    }
+}
+