From: Jason Ish Date: Thu, 26 Jan 2023 17:26:18 +0000 (-0600) Subject: rust: remove explicit lifetimes where not needed X-Git-Tag: suricata-7.0.0-rc1~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7080ecbb76023ef6202436166fa43615c3577da6;p=thirdparty%2Fsuricata.git rust: remove explicit lifetimes where not needed --- diff --git a/rust/src/ike/parser.rs b/rust/src/ike/parser.rs index 6947696df1..dcc5745342 100644 --- a/rust/src/ike/parser.rs +++ b/rust/src/ike/parser.rs @@ -537,8 +537,8 @@ impl fmt::Display for IsakmpPayloadType { } } -pub fn parse_payload<'a>( - payload_type: u8, data: &'a [u8], data_length: u16, domain_of_interpretation: &mut Option, +pub fn parse_payload( + payload_type: u8, data: &[u8], data_length: u16, domain_of_interpretation: &mut Option, key_exchange: &mut Vec, nonce: &mut Vec, transforms: &mut Vec>, vendor_ids: &mut Vec, payload_types: &mut HashSet, ) -> Result<(), ()> { @@ -611,8 +611,8 @@ pub fn parse_payload<'a>( } } -fn parse_proposal_payload<'a>( - data: &'a [u8], data_length: u16, domain_of_interpretation: &mut Option, +fn parse_proposal_payload( + data: &[u8], data_length: u16, domain_of_interpretation: &mut Option, key_exchange: &mut Vec, nonce: &mut Vec, transforms: &mut Vec>, vendor_ids: &mut Vec, payload_types: &mut HashSet, ) -> Result<(), ()> { @@ -658,8 +658,8 @@ fn parse_proposal_payload<'a>( } } -fn parse_security_association_payload<'a>( - data: &'a [u8], data_length: u16, domain_of_interpretation: &mut Option, +fn parse_security_association_payload( + data: &[u8], data_length: u16, domain_of_interpretation: &mut Option, key_exchange: &mut Vec, nonce: &mut Vec, transforms: &mut Vec>, vendor_ids: &mut Vec, payload_types: &mut HashSet, ) -> Result<(), ()> { diff --git a/rust/src/nfs/nfs.rs b/rust/src/nfs/nfs.rs index 475b7b7be1..c396b122b1 100644 --- a/rust/src/nfs/nfs.rs +++ b/rust/src/nfs/nfs.rs @@ -672,7 +672,7 @@ impl NFSState { } } - pub fn process_request_record_lookup<'b>(&mut self, r: &RpcPacket<'b>, xidmap: &mut NFSRequestXidMap) { + pub fn process_request_record_lookup(&mut self, r: &RpcPacket, xidmap: &mut NFSRequestXidMap) { match parse_nfs3_request_lookup(r.prog_data) { Ok((_, lookup)) => { SCLogDebug!("LOOKUP {:?}", lookup); @@ -698,7 +698,7 @@ impl NFSState { } /// complete request record - fn process_request_record<'b>(&mut self, flow: *const Flow, stream_slice: &StreamSlice, r: &RpcPacket<'b>) { + fn process_request_record(&mut self, flow: *const Flow, stream_slice: &StreamSlice, r: &RpcPacket) { SCLogDebug!("REQUEST {} procedure {} ({}) blob size {}", r.hdr.xid, r.procedure, self.requestmap.len(), r.prog_data.len()); @@ -845,7 +845,7 @@ impl NFSState { return self.process_write_record(r, w); } - fn process_reply_record<'b>(&mut self, flow: *const Flow, stream_slice: &StreamSlice, r: &RpcReplyPacket<'b>) -> u32 { + fn process_reply_record(&mut self, flow: *const Flow, stream_slice: &StreamSlice, r: &RpcReplyPacket) -> u32 { let mut xidmap; match self.requestmap.remove(&r.hdr.xid) { Some(p) => { xidmap = p; }, diff --git a/rust/src/nfs/nfs2.rs b/rust/src/nfs/nfs2.rs index 506638a740..f8000b4892 100644 --- a/rust/src/nfs/nfs2.rs +++ b/rust/src/nfs/nfs2.rs @@ -27,7 +27,7 @@ use nom7::number::streaming::be_u32; impl NFSState { /// complete request record - pub fn process_request_record_v2<'b>(&mut self, r: &RpcPacket<'b>) { + pub fn process_request_record_v2(&mut self, r: &RpcPacket) { SCLogDebug!("NFSv2: REQUEST {} procedure {} ({}) blob size {}", r.hdr.xid, r.procedure, self.requestmap.len(), r.prog_data.len()); @@ -92,7 +92,7 @@ impl NFSState { self.requestmap.insert(r.hdr.xid, xidmap); } - pub fn process_reply_record_v2<'b>(&mut self, r: &RpcReplyPacket<'b>, xidmap: &NFSRequestXidMap) { + pub fn process_reply_record_v2(&mut self, r: &RpcReplyPacket, xidmap: &NFSRequestXidMap) { let mut nfs_status = 0; let resp_handle = Vec::new(); diff --git a/rust/src/nfs/nfs3.rs b/rust/src/nfs/nfs3.rs index 0de27d5965..032751f536 100644 --- a/rust/src/nfs/nfs3.rs +++ b/rust/src/nfs/nfs3.rs @@ -29,7 +29,7 @@ use nom7::number::streaming::be_u32; impl NFSState { /// complete NFS3 request record - pub fn process_request_record_v3<'b>(&mut self, r: &RpcPacket<'b>) { + pub fn process_request_record_v3(&mut self, r: &RpcPacket) { SCLogDebug!("REQUEST {} procedure {} ({}) blob size {}", r.hdr.xid, r.procedure, self.requestmap.len(), r.prog_data.len()); @@ -186,7 +186,7 @@ impl NFSState { self.requestmap.insert(r.hdr.xid, xidmap); } - pub fn process_reply_record_v3<'b>(&mut self, r: &RpcReplyPacket<'b>, xidmap: &mut NFSRequestXidMap) { + pub fn process_reply_record_v3(&mut self, r: &RpcReplyPacket, xidmap: &mut NFSRequestXidMap) { let mut nfs_status = 0; let mut resp_handle = Vec::new(); diff --git a/rust/src/nfs/nfs4.rs b/rust/src/nfs/nfs4.rs index 717fa2eff6..b07c35de69 100644 --- a/rust/src/nfs/nfs4.rs +++ b/rust/src/nfs/nfs4.rs @@ -124,8 +124,8 @@ impl NFSState { } } - fn new_tx_v4<'b>( - &mut self, r: &RpcPacket<'b>, xidmap: &NFSRequestXidMap, procedure: u32, + fn new_tx_v4( + &mut self, r: &RpcPacket, xidmap: &NFSRequestXidMap, procedure: u32, _aux_opcodes: &[u32], ) { let mut tx = self.new_tx(); @@ -238,7 +238,7 @@ impl NFSState { } /// complete request record - pub fn process_request_record_v4<'b>(&mut self, r: &RpcPacket<'b>) { + pub fn process_request_record_v4(&mut self, r: &RpcPacket) { SCLogDebug!( "NFSv4 REQUEST {} procedure {} ({}) blob size {}", r.hdr.xid, @@ -381,8 +381,8 @@ impl NFSState { } } - pub fn process_reply_record_v4<'b>( - &mut self, r: &RpcReplyPacket<'b>, xidmap: &mut NFSRequestXidMap, + pub fn process_reply_record_v4( + &mut self, r: &RpcReplyPacket, xidmap: &mut NFSRequestXidMap, ) { if xidmap.procedure == NFSPROC4_COMPOUND { let mut data = r.prog_data; diff --git a/rust/src/smb/dcerpc.rs b/rust/src/smb/dcerpc.rs index ee9d0702f3..b4c5749eac 100644 --- a/rust/src/smb/dcerpc.rs +++ b/rust/src/smb/dcerpc.rs @@ -439,11 +439,11 @@ fn dcerpc_response_handle(tx: &mut SMBTransaction, /// Handle DCERPC reply record. Called for READ, TRANS, IOCTL /// -pub fn smb_read_dcerpc_record<'b>(state: &mut SMBState, +pub fn smb_read_dcerpc_record(state: &mut SMBState, vercmd: SMBVerCmdStat, hdr: SMBCommonHdr, guid: &[u8], - indata: &'b [u8]) -> bool + indata: &[u8]) -> bool { let (_, ntstatus) = vercmd.get_ntstatus(); diff --git a/rust/src/smb/smb.rs b/rust/src/smb/smb.rs index ddd99b37c0..b36b465db5 100644 --- a/rust/src/smb/smb.rs +++ b/rust/src/smb/smb.rs @@ -1267,7 +1267,7 @@ impl SMBState { } /// return bytes consumed - pub fn parse_tcp_data_ts_partial<'b>(&mut self, flow: *const Flow, stream_slice: &StreamSlice, input: &'b[u8]) -> usize + pub fn parse_tcp_data_ts_partial(&mut self, flow: *const Flow, stream_slice: &StreamSlice, input: &[u8]) -> usize { SCLogDebug!("incomplete of size {}", input.len()); if input.len() < 512 { @@ -1595,7 +1595,7 @@ impl SMBState { } /// return bytes consumed - pub fn parse_tcp_data_tc_partial<'b>(&mut self, flow: *const Flow, stream_slice: &StreamSlice, input: &'b[u8]) -> usize + pub fn parse_tcp_data_tc_partial(&mut self, flow: *const Flow, stream_slice: &StreamSlice, input: &[u8]) -> usize { SCLogDebug!("incomplete of size {}", input.len()); if input.len() < 512 { diff --git a/rust/src/smb/smb1.rs b/rust/src/smb/smb1.rs index e6f42ccfcc..c664461557 100644 --- a/rust/src/smb/smb1.rs +++ b/rust/src/smb/smb1.rs @@ -182,7 +182,7 @@ fn smb1_command_is_andx(c: u8) -> bool { } } -fn smb1_request_record_one<'b>(state: &mut SMBState, r: &SmbRecord<'b>, command: u8, andx_offset: &mut usize) { +fn smb1_request_record_one(state: &mut SMBState, r: &SmbRecord, command: u8, andx_offset: &mut usize) { let mut events : Vec = Vec::new(); let mut no_response_expected = false; @@ -580,7 +580,7 @@ fn smb1_request_record_one<'b>(state: &mut SMBState, r: &SmbRecord<'b>, command: } } -pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 { +pub fn smb1_request_record(state: &mut SMBState, r: &SmbRecord) -> u32 { SCLogDebug!("record: command {}: record {:?}", r.command, r); let mut andx_offset = SMB1_HEADER_SIZE; @@ -606,7 +606,7 @@ pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 { 0 } -fn smb1_response_record_one<'b>(state: &mut SMBState, r: &SmbRecord<'b>, command: u8, andx_offset: &mut usize) { +fn smb1_response_record_one(state: &mut SMBState, r: &SmbRecord, command: u8, andx_offset: &mut usize) { SCLogDebug!("record: command {} status {} -> {:?}", r.command, r.nt_status, r); let key_ssn_id = r.ssn_id; @@ -822,7 +822,7 @@ fn smb1_response_record_one<'b>(state: &mut SMBState, r: &SmbRecord<'b>, command } } -pub fn smb1_response_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 { +pub fn smb1_response_record(state: &mut SMBState, r: &SmbRecord) -> u32 { let mut andx_offset = SMB1_HEADER_SIZE; let mut command = r.command; loop { @@ -846,7 +846,7 @@ pub fn smb1_response_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 0 } -pub fn smb1_trans_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) +pub fn smb1_trans_request_record(state: &mut SMBState, r: &SmbRecord) { let mut events : Vec = Vec::new(); @@ -885,7 +885,7 @@ pub fn smb1_trans_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) smb1_request_record_generic(state, r, events); } -pub fn smb1_trans_response_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) +pub fn smb1_trans_response_record(state: &mut SMBState, r: &SmbRecord) { let mut events : Vec = Vec::new(); @@ -932,7 +932,7 @@ pub fn smb1_trans_response_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) } /// Handle WRITE, WRITE_ANDX, WRITE_AND_CLOSE request records -pub fn smb1_write_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>, andx_offset: usize, command: u8) +pub fn smb1_write_request_record(state: &mut SMBState, r: &SmbRecord, andx_offset: usize, command: u8) { let mut events : Vec = Vec::new(); @@ -1019,7 +1019,7 @@ pub fn smb1_write_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>, an smb1_request_record_generic(state, r, events); } -pub fn smb1_read_response_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>, andx_offset: usize) +pub fn smb1_read_response_record(state: &mut SMBState, r: &SmbRecord, andx_offset: usize) { let mut events : Vec = Vec::new(); @@ -1111,7 +1111,7 @@ pub fn smb1_read_response_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>, an /// create a tx for a command / response pair if we're /// configured to do so, or if this is a tx especially /// for setting an event. -fn smb1_request_record_generic<'b>(state: &mut SMBState, r: &SmbRecord<'b>, events: Vec) { +fn smb1_request_record_generic(state: &mut SMBState, r: &SmbRecord, events: Vec) { if smb1_create_new_tx(r.command) || !events.is_empty() { let tx_key = SMBCommonHdr::from1(r, SMBHDR_TYPE_GENERICTX); let tx = state.new_generic_tx(1, r.command as u16, tx_key); @@ -1122,7 +1122,7 @@ fn smb1_request_record_generic<'b>(state: &mut SMBState, r: &SmbRecord<'b>, even /// update or create a tx for a command / reponse pair based /// on the response. We only create a tx for the response side /// if we didn't already update a tx, and we have to set events -fn smb1_response_record_generic<'b>(state: &mut SMBState, r: &SmbRecord<'b>, events: Vec) { +fn smb1_response_record_generic(state: &mut SMBState, r: &SmbRecord, events: Vec) { let tx_key = SMBCommonHdr::from1(r, SMBHDR_TYPE_GENERICTX); if let Some(tx) = state.get_generic_tx(1, r.command as u16, &tx_key) { tx.request_done = true; diff --git a/rust/src/smb/smb1_records.rs b/rust/src/smb/smb1_records.rs index 569c7dfd94..ce3f9194ec 100644 --- a/rust/src/smb/smb1_records.rs +++ b/rust/src/smb/smb1_records.rs @@ -331,7 +331,7 @@ pub fn parse_smb_trans_request_record_data(i: &[u8], Ok((i, req)) } -pub fn parse_smb_trans_request_record<'a, 'b>(i: &'a[u8], r: &SmbRecord<'b>) +pub fn parse_smb_trans_request_record<'a>(i: &'a[u8], r: &SmbRecord) -> IResult<&'a[u8], SmbRecordTransRequest<'a>, SmbError> { let (rem, (params, pipe)) = parse_smb_trans_request_record_params(i)?; diff --git a/rust/src/smb/smb2.rs b/rust/src/smb/smb2.rs index e83e312f1f..685aae487b 100644 --- a/rust/src/smb/smb2.rs +++ b/rust/src/smb/smb2.rs @@ -101,7 +101,7 @@ fn smb2_create_new_tx(cmd: u16) -> bool { } } -fn smb2_read_response_record_generic<'b>(state: &mut SMBState, r: &Smb2Record<'b>) +fn smb2_read_response_record_generic(state: &mut SMBState, r: &Smb2Record) { if smb2_create_new_tx(r.command) { let tx_hdr = SMBCommonHdr::from2(r, SMBHDR_TYPE_GENERICTX); @@ -113,7 +113,7 @@ fn smb2_read_response_record_generic<'b>(state: &mut SMBState, r: &Smb2Record<'b } } -pub fn smb2_read_response_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>) +pub fn smb2_read_response_record(state: &mut SMBState, r: &Smb2Record) { let max_queue_size = unsafe { SMB_CFG_MAX_READ_QUEUE_SIZE }; let max_queue_cnt = unsafe { SMB_CFG_MAX_READ_QUEUE_CNT }; @@ -264,7 +264,7 @@ pub fn smb2_read_response_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>) } } -pub fn smb2_write_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>) +pub fn smb2_write_request_record(state: &mut SMBState, r: &Smb2Record) { let max_queue_size = unsafe { SMB_CFG_MAX_WRITE_QUEUE_SIZE }; let max_queue_cnt = unsafe { SMB_CFG_MAX_WRITE_QUEUE_CNT }; @@ -396,7 +396,7 @@ pub fn smb2_write_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>) } } -pub fn smb2_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>) +pub fn smb2_request_record(state: &mut SMBState, r: &Smb2Record) { SCLogDebug!("SMBv2 request record, command {} tree {} session {}", &smb2_command_string(r.command), r.tree_id, r.session_id); @@ -638,7 +638,7 @@ pub fn smb2_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>) } } -pub fn smb2_response_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>) +pub fn smb2_response_record(state: &mut SMBState, r: &Smb2Record) { SCLogDebug!("SMBv2 response record, command {} status {} tree {} session {} message {}", &smb2_command_string(r.command), r.nt_status, diff --git a/rust/src/smb/smb2_ioctl.rs b/rust/src/smb/smb2_ioctl.rs index 5a3994ecdc..73687aa556 100644 --- a/rust/src/smb/smb2_ioctl.rs +++ b/rust/src/smb/smb2_ioctl.rs @@ -57,7 +57,7 @@ impl SMBState { } // IOCTL responses ASYNC don't set the tree id -pub fn smb2_ioctl_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>) +pub fn smb2_ioctl_request_record(state: &mut SMBState, r: &Smb2Record) { let hdr = SMBCommonHdr::from2(r, SMBHDR_TYPE_HEADER); match parse_smb2_request_ioctl(r.data) { @@ -86,7 +86,7 @@ pub fn smb2_ioctl_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>) } // IOCTL responses ASYNC don't set the tree id -pub fn smb2_ioctl_response_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>) +pub fn smb2_ioctl_response_record(state: &mut SMBState, r: &Smb2Record) { let hdr = SMBCommonHdr::from2(r, SMBHDR_TYPE_HEADER); match parse_smb2_response_ioctl(r.data) {