diff --git a/rust/src/applayertemplate/template.rs b/rust/src/applayertemplate/template.rs index 5c6e87e1ba..1b2c20108f 100644 --- a/rust/src/applayertemplate/template.rs +++ b/rust/src/applayertemplate/template.rs @@ -50,7 +50,7 @@ impl TemplateTransaction { } pub fn free(&mut self) { - if self.events != std::ptr::null_mut() { + if !self.events.is_null() { core::sc_app_layer_decoder_events_free_events(&mut self.events); } if let Some(state) = self.de_state { @@ -287,7 +287,7 @@ pub unsafe extern "C" fn rs_template_probing_parser( _rdir: *mut u8 ) -> AppProto { // Need at least 2 bytes. - if input_len > 1 && input != std::ptr::null_mut() { + if input_len > 1 && !input.is_null() { let slice = build_slice!(input, input_len as usize); if probe(slice).is_ok() { return ALPROTO_TEMPLATE; @@ -340,7 +340,7 @@ pub unsafe extern "C" fn rs_template_parse_request( let state = cast_pointer!(state, TemplateState); - if input == std::ptr::null_mut() && input_len > 0 { + if input.is_null() && input_len > 0 { // Here we have a gap signaled by the input being null, but a greater // than 0 input_len which provides the size of the gap. state.on_request_gap(input_len); @@ -368,7 +368,7 @@ pub unsafe extern "C" fn rs_template_parse_response( }; let state = cast_pointer!(state, TemplateState); - if input == std::ptr::null_mut() && input_len > 0 { + if input.is_null() && input_len > 0 { // Here we have a gap signaled by the input being null, but a greater // than 0 input_len which provides the size of the gap. state.on_response_gap(input_len); diff --git a/rust/src/dcerpc/dcerpc.rs b/rust/src/dcerpc/dcerpc.rs index f91db9831c..6dec6e22cb 100644 --- a/rust/src/dcerpc/dcerpc.rs +++ b/rust/src/dcerpc/dcerpc.rs @@ -1158,7 +1158,7 @@ pub unsafe extern "C" fn rs_dcerpc_parse_request( if flags & (core::STREAM_START|core::STREAM_MIDSTREAM) == (core::STREAM_START|core::STREAM_MIDSTREAM) { state.ts_gap = true; } - if input_len > 0 && input != std::ptr::null_mut() { + if input_len > 0 && !input.is_null() { let buf = build_slice!(input, input_len as usize); state.flow = Some(flow); return state.handle_input_data(buf, core::STREAM_TOSERVER); @@ -1180,7 +1180,7 @@ pub unsafe extern "C" fn rs_dcerpc_parse_response( state.tc_gap = true; } if input_len > 0 { - if input != std::ptr::null_mut() { + if !input.is_null() { let buf = build_slice!(input, input_len as usize); state.flow = Some(flow); return state.handle_input_data(buf, core::STREAM_TOCLIENT); diff --git a/rust/src/dcerpc/dcerpc_udp.rs b/rust/src/dcerpc/dcerpc_udp.rs index b71dfe18d2..0ece8025ef 100644 --- a/rust/src/dcerpc/dcerpc_udp.rs +++ b/rust/src/dcerpc/dcerpc_udp.rs @@ -210,7 +210,7 @@ pub unsafe extern "C" fn rs_dcerpc_udp_parse( input: *const u8, input_len: u32, _data: *const std::os::raw::c_void, _flags: u8, ) -> AppLayerResult { let state = cast_pointer!(state, DCERPCUDPState); - if input_len > 0 && input != std::ptr::null_mut() { + if input_len > 0 && !input.is_null() { let buf = build_slice!(input, input_len as usize); return state.handle_input_data(buf); } diff --git a/rust/src/dcerpc/detect.rs b/rust/src/dcerpc/detect.rs index 3a8fb632d7..7cc3a59977 100644 --- a/rust/src/dcerpc/detect.rs +++ b/rust/src/dcerpc/detect.rs @@ -288,7 +288,7 @@ pub unsafe extern "C" fn rs_dcerpc_iface_parse(carg: *const c_char) -> *mut c_vo #[no_mangle] pub unsafe extern "C" fn rs_dcerpc_iface_free(ptr: *mut c_void) { - if ptr != std::ptr::null_mut() { + if !ptr.is_null() { std::mem::drop(Box::from_raw(ptr as *mut DCEIfaceData)); } } @@ -335,7 +335,7 @@ pub unsafe extern "C" fn rs_dcerpc_opnum_parse(carg: *const c_char) -> *mut c_vo #[no_mangle] pub unsafe extern "C" fn rs_dcerpc_opnum_free(ptr: *mut c_void) { - if ptr != std::ptr::null_mut() { + if !ptr.is_null() { std::mem::drop(Box::from_raw(ptr as *mut DCEOpnumData)); } } diff --git a/rust/src/dhcp/dhcp.rs b/rust/src/dhcp/dhcp.rs index 7d8ce68943..8748b4600b 100644 --- a/rust/src/dhcp/dhcp.rs +++ b/rust/src/dhcp/dhcp.rs @@ -96,7 +96,7 @@ impl DHCPTransaction { } pub fn free(&mut self) { - if self.events != std::ptr::null_mut() { + if !self.events.is_null() { sc_app_layer_decoder_events_free_events(&mut self.events); } match self.de_state { diff --git a/rust/src/dns/detect.rs b/rust/src/dns/detect.rs index b389d2c57f..ae64614b14 100644 --- a/rust/src/dns/detect.rs +++ b/rust/src/dns/detect.rs @@ -115,7 +115,7 @@ pub unsafe extern "C" fn rs_detect_dns_opcode_parse(carg: *const c_char) -> *mut #[no_mangle] pub unsafe extern "C" fn rs_dns_detect_opcode_free(ptr: *mut c_void) { - if ptr != std::ptr::null_mut() { + if !ptr.is_null() { std::mem::drop(Box::from_raw(ptr as *mut DetectDnsOpcode)); } } diff --git a/rust/src/dns/dns.rs b/rust/src/dns/dns.rs index 3e0031e3e9..e0ac05fea8 100644 --- a/rust/src/dns/dns.rs +++ b/rust/src/dns/dns.rs @@ -250,7 +250,7 @@ impl DNSTransaction { } pub fn free(&mut self) { - if self.events != std::ptr::null_mut() { + if !self.events.is_null() { core::sc_app_layer_decoder_events_free_events(&mut self.events); } match self.de_state { @@ -719,7 +719,7 @@ pub unsafe extern "C" fn rs_dns_parse_request_tcp(_flow: *const core::Flow, -> AppLayerResult { let state = cast_pointer!(state, DNSState); if input_len > 0 { - if input != std::ptr::null_mut() { + if !input.is_null() { let buf = std::slice::from_raw_parts(input, input_len as usize); return state.parse_request_tcp(buf); } @@ -739,7 +739,7 @@ pub unsafe extern "C" fn rs_dns_parse_response_tcp(_flow: *const core::Flow, -> AppLayerResult { let state = cast_pointer!(state, DNSState); if input_len > 0 { - if input != std::ptr::null_mut() { + if !input.is_null() { let buf = std::slice::from_raw_parts(input, input_len as usize); return state.parse_response_tcp(buf); } diff --git a/rust/src/http2/http2.rs b/rust/src/http2/http2.rs index 3cbbf1d2b3..0bea3e2d9c 100644 --- a/rust/src/http2/http2.rs +++ b/rust/src/http2/http2.rs @@ -166,13 +166,13 @@ impl HTTP2Transaction { } pub fn free(&mut self) { - if self.events != std::ptr::null_mut() { + if !self.events.is_null() { core::sc_app_layer_decoder_events_free_events(&mut self.events); } if let Some(state) = self.de_state { core::sc_detect_engine_state_free(state); } - if self.file_range != std::ptr::null_mut() { + if !self.file_range.is_null() { match unsafe { SC } { None => panic!("BUG no suricata_config"), Some(c) => { @@ -224,7 +224,7 @@ impl HTTP2Transaction { match range::http2_parse_check_content_range(&value) { Ok((_, v)) => { range::http2_range_open(self, &v, flow, sfcm, flags, decompressed); - if over && self.file_range != std::ptr::null_mut() { + if over && !self.file_range.is_null() { range::http2_range_close(self, files, flags, &[]) } } @@ -234,7 +234,7 @@ impl HTTP2Transaction { } } } else { - if self.file_range != std::ptr::null_mut() { + if !self.file_range.is_null() { if over { range::http2_range_close(self, files, flags, decompressed) } else { @@ -1008,7 +1008,7 @@ export_tx_data_get!(rs_http2_get_tx_data, HTTP2Transaction); pub unsafe extern "C" fn rs_http2_probing_parser_tc( _flow: *const Flow, _direction: u8, input: *const u8, input_len: u32, _rdir: *mut u8, ) -> AppProto { - if input != std::ptr::null_mut() { + if !input.is_null() { let slice = build_slice!(input, input_len as usize); match parser::http2_parse_frame_header(slice) { Ok((_, header)) => { @@ -1049,7 +1049,7 @@ pub extern "C" fn rs_http2_state_new( let state = HTTP2State::new(); let boxed = Box::new(state); let r = Box::into_raw(boxed) as *mut _; - if orig_state != std::ptr::null_mut() { + if !orig_state.is_null() { //we could check ALPROTO_HTTP1 == orig_proto unsafe { HTTP2MimicHttp1Request(orig_state, r); diff --git a/rust/src/ike/ike.rs b/rust/src/ike/ike.rs index 6787c22a28..8bdb5e051e 100644 --- a/rust/src/ike/ike.rs +++ b/rust/src/ike/ike.rs @@ -129,7 +129,7 @@ impl IKETransaction { } pub fn free(&mut self) { - if self.events != std::ptr::null_mut() { + if !self.events.is_null() { core::sc_app_layer_decoder_events_free_events(&mut self.events); } if let Some(state) = self.de_state { @@ -316,7 +316,7 @@ pub unsafe extern "C" fn rs_ike_probing_parser( return ALPROTO_FAILED; } - if input != std::ptr::null_mut() { + if !input.is_null() { let slice = build_slice!(input, input_len as usize); if probe(slice, direction, rdir) { return ALPROTO_IKE ; diff --git a/rust/src/krb/krb5.rs b/rust/src/krb/krb5.rs index 8d6bdd5ea8..95271a84be 100644 --- a/rust/src/krb/krb5.rs +++ b/rust/src/krb/krb5.rs @@ -235,7 +235,7 @@ impl KRB5Transaction { impl Drop for KRB5Transaction { fn drop(&mut self) { - if self.events != std::ptr::null_mut() { + if !self.events.is_null() { core::sc_app_layer_decoder_events_free_events(&mut self.events); } if let Some(state) = self.de_state { diff --git a/rust/src/mqtt/mqtt.rs b/rust/src/mqtt/mqtt.rs index 15e62920cd..9e5d198f42 100644 --- a/rust/src/mqtt/mqtt.rs +++ b/rust/src/mqtt/mqtt.rs @@ -84,7 +84,7 @@ impl MQTTTransaction { } pub fn free(&mut self) { - if self.events != std::ptr::null_mut() { + if !self.events.is_null() { core::sc_app_layer_decoder_events_free_events(&mut self.events); } if let Some(state) = self.de_state { diff --git a/rust/src/nfs/nfs.rs b/rust/src/nfs/nfs.rs index 4df1f403fa..c11f5f49d3 100644 --- a/rust/src/nfs/nfs.rs +++ b/rust/src/nfs/nfs.rs @@ -217,7 +217,7 @@ impl NFSTransaction { pub fn free(&mut self) { debug_validate_bug_on!(self.tx_data.files_opened > 1); debug_validate_bug_on!(self.tx_data.files_logged > 1); - if self.events != std::ptr::null_mut() { + if !self.events.is_null() { sc_app_layer_decoder_events_free_events(&mut self.events); } match self.de_state { diff --git a/rust/src/ntp/ntp.rs b/rust/src/ntp/ntp.rs index 9b8b6abf6a..175d53cf3d 100644 --- a/rust/src/ntp/ntp.rs +++ b/rust/src/ntp/ntp.rs @@ -149,7 +149,7 @@ impl NTPTransaction { } fn free(&mut self) { - if self.events != std::ptr::null_mut() { + if !self.events.is_null() { core::sc_app_layer_decoder_events_free_events(&mut self.events); } } diff --git a/rust/src/rdp/rdp.rs b/rust/src/rdp/rdp.rs index e86b6dd165..8b197b5982 100644 --- a/rust/src/rdp/rdp.rs +++ b/rust/src/rdp/rdp.rs @@ -410,7 +410,7 @@ fn probe_rdp(input: &[u8]) -> bool { pub unsafe extern "C" fn rs_rdp_probe_ts_tc( _flow: *const Flow, _direction: u8, input: *const u8, input_len: u32, _rdir: *mut u8, ) -> AppProto { - if input != std::ptr::null_mut() { + if !input.is_null() { // probe bytes for `rdp` protocol pattern let slice = build_slice!(input, input_len as usize); diff --git a/rust/src/rfb/rfb.rs b/rust/src/rfb/rfb.rs index e61d787abc..d9b6d543cf 100644 --- a/rust/src/rfb/rfb.rs +++ b/rust/src/rfb/rfb.rs @@ -75,7 +75,7 @@ impl RFBTransaction { } pub fn free(&mut self) { - if self.events != std::ptr::null_mut() { + if !self.events.is_null() { core::sc_app_layer_decoder_events_free_events(&mut self.events); } if let Some(state) = self.de_state { diff --git a/rust/src/sip/sip.rs b/rust/src/sip/sip.rs index e9b1555078..df31c56b70 100755 --- a/rust/src/sip/sip.rs +++ b/rust/src/sip/sip.rs @@ -149,7 +149,7 @@ impl SIPTransaction { impl Drop for SIPTransaction { fn drop(&mut self) { - if self.events != std::ptr::null_mut() { + if !self.events.is_null() { core::sc_app_layer_decoder_events_free_events(&mut self.events); } if let Some(state) = self.de_state { diff --git a/rust/src/smb/smb.rs b/rust/src/smb/smb.rs index f178de87ae..2eea29f691 100644 --- a/rust/src/smb/smb.rs +++ b/rust/src/smb/smb.rs @@ -568,7 +568,7 @@ impl SMBTransaction { pub fn free(&mut self) { debug_validate_bug_on!(self.tx_data.files_opened > 1); debug_validate_bug_on!(self.tx_data.files_logged > 1); - if self.events != std::ptr::null_mut() { + if !self.events.is_null() { sc_app_layer_decoder_events_free_events(&mut self.events); } match self.de_state { diff --git a/rust/src/snmp/snmp.rs b/rust/src/snmp/snmp.rs index 2789ef185e..b12427ab9c 100644 --- a/rust/src/snmp/snmp.rs +++ b/rust/src/snmp/snmp.rs @@ -267,7 +267,7 @@ impl<'a> SNMPTransaction<'a> { } fn free(&mut self) { - if self.events != std::ptr::null_mut() { + if !self.events.is_null() { core::sc_app_layer_decoder_events_free_events(&mut self.events); } } diff --git a/rust/src/ssh/ssh.rs b/rust/src/ssh/ssh.rs index 70494f5fc1..7a09b6db07 100644 --- a/rust/src/ssh/ssh.rs +++ b/rust/src/ssh/ssh.rs @@ -99,7 +99,7 @@ impl SSHTransaction { } pub fn free(&mut self) { - if self.events != std::ptr::null_mut() { + if !self.events.is_null() { core::sc_app_layer_decoder_events_free_events(&mut self.events); } if let Some(state) = self.de_state {