]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/nom4: error_code is superseded by error_position
authorPierre Chifflier <chifflier@wzdftpd.net>
Fri, 8 Feb 2019 09:44:15 +0000 (10:44 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 8 Feb 2019 15:21:44 +0000 (16:21 +0100)
rust/src/kerberos.rs
rust/src/nfs/nfs3.rs
rust/src/nfs/nfs3_records.rs
rust/src/smb/auth.rs
rust/src/smb/dcerpc_records.rs
rust/src/smb/smb_records.rs

index 9d46daf496d6f9606d0aa713e5a1be9ce6ed8117..170f15977d9c53edee1c759e316e99304ed162f0 100644 (file)
@@ -38,7 +38,7 @@ fn parse_kerberos5_request_do(blob: &[u8]) -> IResult<&[u8], ApReq>
         IResult::Done(_, b) => {
             match b.content.as_slice() {
                 Ok(b) => { b },
-                _ => { return IResult::Error(error_code!(ErrorKind::Custom(SECBLOB_KRB_FMT_ERR))); },
+                _ => { return IResult::Error(error_position!(blob,ErrorKind::Custom(SECBLOB_KRB_FMT_ERR))); },
             }
         },
         IResult::Incomplete(needed) => { return IResult::Incomplete(needed); },
index a76b0a3f2cad5975227ed834c6473eeaa95a24de..12437015e4a9d9371084950032f2a3c2a56535ef 100644 (file)
@@ -27,14 +27,6 @@ use nfs::types::*;
 use nfs::rpc_records::*;
 use nfs::nfs3_records::*;
 
-/// nom bug leads to this wrappers being necessary
-/// TODO for some reason putting these in parser.rs and making them public
-/// leads to a compile error wrt an unknown lifetime identifier 'a
-//named!(many0_nfs3_request_objects<Vec<Nfs3RequestObject<'a>>>, many0!(parse_nfs3_request_object));
-//named!(many0_nfs3_reply_objects<Vec<Nfs3ReplyObject<'a>>>, many0!(parse_nfs3_reply_object));
-named!(many0_nfs3_response_readdirplus_entries<Vec<Nfs3ResponseReaddirplusEntry<'a>>>,
-        many0!(parse_nfs3_response_readdirplus_entry_cond));
-
 impl NFSState {
     /// complete NFS3 request record
     pub fn process_request_record_v3<'b>(&mut self, r: &RpcPacket<'b>) -> u32 {
index 41e88679fc9fcf48ec561b923e0b2810845edc2b..9659c626f51091b8ac6c6bf746e4884b370d0aa7 100644 (file)
@@ -17,7 +17,7 @@
 
 //! Nom parsers for RPC & NFSv3
 
-use nom::{be_u32, be_u64, rest};
+use nom::{IResult, be_u32, be_u64, rest};
 use nfs::nfs_records::*;
 
 #[derive(Debug,PartialEq)]
@@ -346,6 +346,10 @@ named!(pub parse_nfs3_response_readdirplus<Nfs3ResponseReaddirplus>,
         } ))
 );
 
+pub(crate) fn many0_nfs3_response_readdirplus_entries<'a>(input: &'a [u8]) -> IResult<&'a[u8], Vec<Nfs3ResponseReaddirplusEntry<'a>>> {
+    many0!(input, complete!(parse_nfs3_response_readdirplus_entry_cond))
+}
+
 #[derive(Debug,PartialEq)]
 pub struct Nfs3RequestReaddirplus<'a> {
     pub handle: Nfs3Handle<'a>,
index 24292be6bbd96f7eef00659ef76f2c85f1975905..68c63fbf67b0e9ab2320bd2af4af17dc0efa12d8 100644 (file)
@@ -33,7 +33,7 @@ fn parse_secblob_get_spnego(blob: &[u8]) -> IResult<&[u8], &[u8]>
     };
     SCLogDebug!("parse_secblob_get_spnego: base_o {:?}", base_o);
     let d = match base_o.content.as_slice() {
-        Err(_) => { return IResult::Error(error_code!(ErrorKind::Custom(SECBLOB_NOT_SPNEGO))); },
+        Err(_) => { return IResult::Error(error_position!(blob,ErrorKind::Custom(SECBLOB_NOT_SPNEGO))); },
         Ok(d) => d,
     };
     let (next, o) = match der_parser::parse_der_oid(d) {
@@ -46,7 +46,7 @@ fn parse_secblob_get_spnego(blob: &[u8]) -> IResult<&[u8], &[u8]>
     let oid = match o.content.as_oid() {
         Ok(oid) => oid,
         Err(_) => {
-            return IResult::Error(error_code!(ErrorKind::Custom(SECBLOB_NOT_SPNEGO)));
+            return IResult::Error(error_position!(blob,ErrorKind::Custom(SECBLOB_NOT_SPNEGO)));
         },
     };
     SCLogDebug!("oid {}", oid.to_string());
@@ -56,7 +56,7 @@ fn parse_secblob_get_spnego(blob: &[u8]) -> IResult<&[u8], &[u8]>
             SCLogDebug!("SPNEGO {}", oid);
         },
         _ => {
-            return IResult::Error(error_code!(ErrorKind::Custom(SECBLOB_NOT_SPNEGO)));
+            return IResult::Error(error_position!(blob,ErrorKind::Custom(SECBLOB_NOT_SPNEGO)));
         },
     }
 
@@ -81,7 +81,7 @@ fn parse_secblob_spnego_start(blob: &[u8]) -> IResult<&[u8], &[u8]>
             d
         },
         _ => {
-            return IResult::Error(error_code!(ErrorKind::Custom(SECBLOB_NOT_SPNEGO)));
+            return IResult::Error(error_position!(blob,ErrorKind::Custom(SECBLOB_NOT_SPNEGO)));
         },
     };
     IResult::Done(rem, d)
index b4ed08f39e7381af549550375a9317f686b8c414..d614750b91b6d04b3cae71715f5cc76a56ae06ff 100644 (file)
@@ -28,7 +28,7 @@ pub fn parse_dcerpc_response_record(i:&[u8], frag_len: u16 )
     -> IResult<&[u8], DceRpcResponseRecord>
 {
     if frag_len < 24 {
-        return IResult::Error(error_code!(ErrorKind::Custom(128)));
+        return IResult::Error(error_position!(i,ErrorKind::Custom(128)));
     }
     do_parse!(i,
                 take!(8)
@@ -51,7 +51,7 @@ pub fn parse_dcerpc_request_record(i:&[u8], frag_len: u16, little: bool)
     -> IResult<&[u8], DceRpcRequestRecord>
 {
     if frag_len < 24 {
-        return IResult::Error(error_code!(ErrorKind::Custom(128)));
+        return IResult::Error(error_position!(i,ErrorKind::Custom(128)));
     }
     do_parse!(i,
                 take!(6)
index 660b1697e91cefb44f8ac407bf0a45ab91c6e61a..e09323d967c186b1b72c11428c8a7c6c7fe4beb1 100644 (file)
@@ -41,7 +41,7 @@ pub fn smb_get_unicode_string(blob: &[u8]) -> IResult<&[u8], Vec<u8>>
         name.push(c[0]);
         c = &c[2..];
     }
-    IResult::Error(error_code!(ErrorKind::Custom(130)))
+    IResult::Error(error_position!(blob,ErrorKind::Custom(130)))
 }
 
 /// parse an ASCII string that is null terminated