rust/nom4: error_code is superseded by error_position

pull/3646/head
Pierre Chifflier 6 years ago committed by Victor Julien
parent d3011e3ee8
commit 2f08b3eabd

@ -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); },

@ -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 {

@ -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>,

@ -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)

@ -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)

@ -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

Loading…
Cancel
Save