From 2f08b3eabdda6c97e15870db12a752fff9d85e3b Mon Sep 17 00:00:00 2001 From: Pierre Chifflier Date: Fri, 8 Feb 2019 10:44:15 +0100 Subject: [PATCH] rust/nom4: error_code is superseded by error_position --- rust/src/kerberos.rs | 2 +- rust/src/nfs/nfs3.rs | 8 -------- rust/src/nfs/nfs3_records.rs | 6 +++++- rust/src/smb/auth.rs | 8 ++++---- rust/src/smb/dcerpc_records.rs | 4 ++-- rust/src/smb/smb_records.rs | 2 +- 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/rust/src/kerberos.rs b/rust/src/kerberos.rs index 9d46daf496..170f15977d 100644 --- a/rust/src/kerberos.rs +++ b/rust/src/kerberos.rs @@ -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); }, diff --git a/rust/src/nfs/nfs3.rs b/rust/src/nfs/nfs3.rs index a76b0a3f2c..12437015e4 100644 --- a/rust/src/nfs/nfs3.rs +++ b/rust/src/nfs/nfs3.rs @@ -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>>, many0!(parse_nfs3_request_object)); -//named!(many0_nfs3_reply_objects>>, many0!(parse_nfs3_reply_object)); -named!(many0_nfs3_response_readdirplus_entries>>, - 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 { diff --git a/rust/src/nfs/nfs3_records.rs b/rust/src/nfs/nfs3_records.rs index 41e88679fc..9659c626f5 100644 --- a/rust/src/nfs/nfs3_records.rs +++ b/rust/src/nfs/nfs3_records.rs @@ -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, } )) ); +pub(crate) fn many0_nfs3_response_readdirplus_entries<'a>(input: &'a [u8]) -> IResult<&'a[u8], Vec>> { + many0!(input, complete!(parse_nfs3_response_readdirplus_entry_cond)) +} + #[derive(Debug,PartialEq)] pub struct Nfs3RequestReaddirplus<'a> { pub handle: Nfs3Handle<'a>, diff --git a/rust/src/smb/auth.rs b/rust/src/smb/auth.rs index 24292be6bb..68c63fbf67 100644 --- a/rust/src/smb/auth.rs +++ b/rust/src/smb/auth.rs @@ -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) diff --git a/rust/src/smb/dcerpc_records.rs b/rust/src/smb/dcerpc_records.rs index b4ed08f39e..d614750b91 100644 --- a/rust/src/smb/dcerpc_records.rs +++ b/rust/src/smb/dcerpc_records.rs @@ -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) diff --git a/rust/src/smb/smb_records.rs b/rust/src/smb/smb_records.rs index 660b1697e9..e09323d967 100644 --- a/rust/src/smb/smb_records.rs +++ b/rust/src/smb/smb_records.rs @@ -41,7 +41,7 @@ pub fn smb_get_unicode_string(blob: &[u8]) -> IResult<&[u8], Vec> 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