rust: SCLogDebug is real nop when built as release

Before, even if there were no outputs, all the arguments
were evaluated, which could turn expensive

All variables which are used only in certain build configurations
are now prefixed by underscore to avoid warnings
pull/6197/head
Philippe Antoine 5 years ago committed by Victor Julien
parent 20e8f90981
commit ef5755338f

@ -102,22 +102,22 @@ named!(pub parse_dcerpc_udp_header<DCERPCHdrUdp>,
serial_hi: serial_hi, serial_hi: serial_hi,
objectuuid: match parse_uuid(objectuuid) { objectuuid: match parse_uuid(objectuuid) {
Ok((_, vect)) => assemble_uuid(vect), Ok((_, vect)) => assemble_uuid(vect),
Err(e) => { Err(_e) => {
SCLogDebug!("{}", e); SCLogDebug!("{}", _e);
vec![0] vec![0]
}, },
}, },
interfaceuuid: match parse_uuid(interfaceuuid) { interfaceuuid: match parse_uuid(interfaceuuid) {
Ok((_, vect)) => assemble_uuid(vect), Ok((_, vect)) => assemble_uuid(vect),
Err(e) => { Err(_e) => {
SCLogDebug!("{}", e); SCLogDebug!("{}", _e);
vec![0] vec![0]
}, },
}, },
activityuuid: match parse_uuid(activityuuid){ activityuuid: match parse_uuid(activityuuid){
Ok((_, vect)) => assemble_uuid(vect), Ok((_, vect)) => assemble_uuid(vect),
Err(e) => { Err(_e) => {
SCLogDebug!("{}", e); SCLogDebug!("{}", _e);
vec![0] vec![0]
}, },
}, },

@ -111,10 +111,10 @@ impl FileTransferTracker {
self.file_is_truncated = true; self.file_is_truncated = true;
} }
pub fn create(&mut self, name: &[u8], file_size: u64) { pub fn create(&mut self, _name: &[u8], _file_size: u64) {
if self.file_open == true { panic!("close existing file first"); } if self.file_open == true { panic!("close existing file first"); }
SCLogDebug!("CREATE: name {:?} file_size {}", name, file_size); SCLogDebug!("CREATE: name {:?} file_size {}", _name, _file_size);
} }
pub fn new_chunk(&mut self, config: &'static SuricataFileContext, pub fn new_chunk(&mut self, config: &'static SuricataFileContext,
@ -245,7 +245,7 @@ impl FileTransferTracker {
if self.chunk_is_ooo == false { if self.chunk_is_ooo == false {
loop { loop {
let offset = self.tracked; let _offset = self.tracked;
match self.chunks.remove(&self.tracked) { match self.chunks.remove(&self.tracked) {
Some(c) => { Some(c) => {
let res = files.file_append(&self.track_id, &c.chunk, c.contains_gap); let res = files.file_append(&self.track_id, &c.chunk, c.contains_gap);
@ -263,10 +263,10 @@ impl FileTransferTracker {
self.tracked += c.chunk.len() as u64; self.tracked += c.chunk.len() as u64;
self.cur_ooo -= c.chunk.len() as u64; self.cur_ooo -= c.chunk.len() as u64;
SCLogDebug!("STORED OOO CHUNK at offset {}, tracked now {}, stored len {}", offset, self.tracked, c.chunk.len()); SCLogDebug!("STORED OOO CHUNK at offset {}, tracked now {}, stored len {}", _offset, self.tracked, c.chunk.len());
}, },
_ => { _ => {
SCLogDebug!("NO STORED CHUNK found at offset {}", self.tracked); SCLogDebug!("NO STORED CHUNK found at _offset {}", self.tracked);
break; break;
}, },
}; };

@ -101,11 +101,9 @@ pub extern "C" fn rs_ftp_pasv_response(input: *const u8, len: u32) -> u16 {
return dport; return dport;
}, },
Err(nom::Err::Incomplete(_)) => { Err(nom::Err::Incomplete(_)) => {
let buf = unsafe{std::slice::from_raw_parts(input, len as usize)};
SCLogDebug!("pasv incomplete: '{:?}'", String::from_utf8_lossy(buf)); SCLogDebug!("pasv incomplete: '{:?}'", String::from_utf8_lossy(buf));
}, },
Err(_) => { Err(_) => {
let buf = unsafe{std::slice::from_raw_parts(input, len as usize)};
SCLogDebug!("pasv error on '{:?}'", String::from_utf8_lossy(buf)); SCLogDebug!("pasv error on '{:?}'", String::from_utf8_lossy(buf));
}, },
} }
@ -166,11 +164,9 @@ pub extern "C" fn rs_ftp_epsv_response(input: *const u8, len: u32) -> u16 {
return dport; return dport;
}, },
Err(nom::Err::Incomplete(_)) => { Err(nom::Err::Incomplete(_)) => {
let buf = unsafe{std::slice::from_raw_parts(input, len as usize)};
SCLogDebug!("epsv incomplete: '{:?}'", String::from_utf8_lossy(buf)); SCLogDebug!("epsv incomplete: '{:?}'", String::from_utf8_lossy(buf));
}, },
Err(_) => { Err(_) => {
let buf = unsafe{std::slice::from_raw_parts(input, len as usize)};
SCLogDebug!("epsv incomplete: '{:?}'", String::from_utf8_lossy(buf)); SCLogDebug!("epsv incomplete: '{:?}'", String::from_utf8_lossy(buf));
}, },

@ -149,8 +149,8 @@ pub fn handle_ikev2(
state.ikev2_container.dh_group = kex.dh_group; state.ikev2_container.dh_group = kex.dh_group;
} }
} }
IkeV2PayloadContent::Nonce(ref n) => { IkeV2PayloadContent::Nonce(ref _n) => {
SCLogDebug!("Nonce: {:?}", n); SCLogDebug!("Nonce: {:?}", _n);
} }
IkeV2PayloadContent::Notify(ref n) => { IkeV2PayloadContent::Notify(ref n) => {
SCLogDebug!("Notify: {:?}", n); SCLogDebug!("Notify: {:?}", n);
@ -207,8 +207,8 @@ pub fn handle_ikev2(
} }
} }
} }
e => { _e => {
SCLogDebug!("parse_ikev2_payload_with_type: {:?}", e); SCLogDebug!("parse_ikev2_payload_with_type: {:?}", _e);
() ()
} }
} }
@ -285,8 +285,8 @@ fn add_proposals(state: &mut IKEState, prop: &Vec<IkeV2Proposal>, direction: u8)
} }
_ => (), _ => (),
}, },
IkeV2Transform::Unknown(tx_type, tx_id) => { IkeV2Transform::Unknown(_tx_type, _tx_id) => {
SCLogDebug!("Unknown proposal: type={:?}, id={}", tx_type, tx_id); SCLogDebug!("Unknown proposal: type={:?}, id={}", _tx_type, _tx_id);
state.set_event(IkeEvent::UnknownProposal); state.set_event(IkeEvent::UnknownProposal);
} }
_ => (), _ => (),

@ -167,8 +167,7 @@ macro_rules!SCLogDebug {
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
#[macro_export] #[macro_export]
macro_rules!SCLogDebug { macro_rules!SCLogDebug {
($last:expr) => { let _ = &$last; let _ = $crate::log::Level::Debug; }; ($($arg:tt)*) => ()
($one:expr, $($arg:tt)*) => { let _ = &$one; SCLogDebug!($($arg)*); };
} }
/// SCLogMessage wrapper. If the Suricata C context is not registered /// SCLogMessage wrapper. If the Suricata C context is not registered

@ -1017,9 +1017,9 @@ impl NFSState {
if self.ts_gap { if self.ts_gap {
SCLogDebug!("TS trying to catch up after GAP (input {})", cur_i.len()); SCLogDebug!("TS trying to catch up after GAP (input {})", cur_i.len());
let mut cnt = 0; let mut _cnt = 0;
while cur_i.len() > 0 { while cur_i.len() > 0 {
cnt += 1; _cnt += 1;
match nfs_probe(cur_i, STREAM_TOSERVER) { match nfs_probe(cur_i, STREAM_TOSERVER) {
1 => { 1 => {
SCLogDebug!("expected data found"); SCLogDebug!("expected data found");
@ -1028,13 +1028,13 @@ impl NFSState {
}, },
0 => { 0 => {
SCLogDebug!("incomplete, queue and retry with the next block (input {}). Looped {} times.", SCLogDebug!("incomplete, queue and retry with the next block (input {}). Looped {} times.",
cur_i.len(), cnt); cur_i.len(), _cnt);
return AppLayerResult::incomplete((i.len() - cur_i.len()) as u32, (cur_i.len() + 1) as u32); return AppLayerResult::incomplete((i.len() - cur_i.len()) as u32, (cur_i.len() + 1) as u32);
}, },
-1 => { -1 => {
cur_i = &cur_i[1..]; cur_i = &cur_i[1..];
if cur_i.len() == 0 { if cur_i.len() == 0 {
SCLogDebug!("all post-GAP data in this chunk was bad. Looped {} times.", cnt); SCLogDebug!("all post-GAP data in this chunk was bad. Looped {} times.", _cnt);
} }
}, },
_ => { _ => {
@ -1170,9 +1170,9 @@ impl NFSState {
if self.tc_gap { if self.tc_gap {
SCLogDebug!("TC trying to catch up after GAP (input {})", cur_i.len()); SCLogDebug!("TC trying to catch up after GAP (input {})", cur_i.len());
let mut cnt = 0; let mut _cnt = 0;
while cur_i.len() > 0 { while cur_i.len() > 0 {
cnt += 1; _cnt += 1;
match nfs_probe(cur_i, STREAM_TOCLIENT) { match nfs_probe(cur_i, STREAM_TOCLIENT) {
1 => { 1 => {
SCLogDebug!("expected data found"); SCLogDebug!("expected data found");
@ -1181,13 +1181,13 @@ impl NFSState {
}, },
0 => { 0 => {
SCLogDebug!("incomplete, queue and retry with the next block (input {}). Looped {} times.", SCLogDebug!("incomplete, queue and retry with the next block (input {}). Looped {} times.",
cur_i.len(), cnt); cur_i.len(), _cnt);
return AppLayerResult::incomplete((i.len() - cur_i.len()) as u32, (cur_i.len() + 1) as u32); return AppLayerResult::incomplete((i.len() - cur_i.len()) as u32, (cur_i.len() + 1) as u32);
}, },
-1 => { -1 => {
cur_i = &cur_i[1..]; cur_i = &cur_i[1..];
if cur_i.len() == 0 { if cur_i.len() == 0 {
SCLogDebug!("all post-GAP data in this chunk was bad. Looped {} times.", cnt); SCLogDebug!("all post-GAP data in this chunk was bad. Looped {} times.", _cnt);
} }
}, },
_ => { _ => {

@ -186,8 +186,8 @@ impl NFSState {
self.commit_v4(r, fh); self.commit_v4(r, fh);
} }
} }
&Nfs4RequestContent::Close(ref rd) => { &Nfs4RequestContent::Close(ref _rd) => {
SCLogDebug!("CLOSEv4: {:?}", rd); SCLogDebug!("CLOSEv4: {:?}", _rd);
} }
&Nfs4RequestContent::Create(ref rd) => { &Nfs4RequestContent::Create(ref rd) => {
SCLogDebug!("CREATEv4: {:?}", rd); SCLogDebug!("CREATEv4: {:?}", rd);
@ -202,11 +202,11 @@ impl NFSState {
xidmap.file_name = rd.to_vec(); xidmap.file_name = rd.to_vec();
main_opcode = NFSPROC4_REMOVE; main_opcode = NFSPROC4_REMOVE;
} }
&Nfs4RequestContent::SetClientId(ref rd) => { &Nfs4RequestContent::SetClientId(ref _rd) => {
SCLogDebug!("SETCLIENTIDv4: client id {} r_netid {} r_addr {}", SCLogDebug!("SETCLIENTIDv4: client id {} r_netid {} r_addr {}",
String::from_utf8_lossy(&rd.client_id), String::from_utf8_lossy(&_rd.client_id),
String::from_utf8_lossy(&rd.r_netid), String::from_utf8_lossy(&_rd.r_netid),
String::from_utf8_lossy(&rd.r_addr)); String::from_utf8_lossy(&_rd.r_addr));
} }
&_ => { }, &_ => { },
} }
@ -291,13 +291,13 @@ impl NFSState {
for c in &cr.commands { for c in &cr.commands {
SCLogDebug!("c {:?}", c); SCLogDebug!("c {:?}", c);
match c { match c {
&Nfs4ResponseContent::ReadDir(s, ref rd) => { &Nfs4ResponseContent::ReadDir(_s, ref rd) => {
if let &Some(ref rd) = rd { if let &Some(ref rd) = rd {
SCLogDebug!("READDIRv4: status {} eof {}", s, rd.eof); SCLogDebug!("READDIRv4: status {} eof {}", _s, rd.eof);
for d in &rd.listing { for d in &rd.listing {
if let &Some(ref d) = d { if let &Some(ref _d) = d {
SCLogDebug!("READDIRv4: dir {}", String::from_utf8_lossy(&d.name)); SCLogDebug!("READDIRv4: dir {}", String::from_utf8_lossy(&_d.name));
} }
} }
@ -329,9 +329,9 @@ impl NFSState {
self.process_read_record(r, &reply, Some(&xidmap)); self.process_read_record(r, &reply, Some(&xidmap));
} }
}, },
&Nfs4ResponseContent::Open(s, ref rd) => { &Nfs4ResponseContent::Open(_s, ref rd) => {
if let &Some(ref rd) = rd { if let &Some(ref _rd) = rd {
SCLogDebug!("OPENv4: status {} opendata {:?}", s, rd); SCLogDebug!("OPENv4: status {} opendata {:?}", _s, _rd);
insert_filename_with_getfh = true; insert_filename_with_getfh = true;
} }
}, },

@ -273,10 +273,10 @@ pub fn smb_write_dcerpc_record<'b>(state: &mut SMBState,
i.iface.to_vec() i.iface.to_vec()
}; };
let uuid_str = uuid::Uuid::from_slice(&x.clone()); let uuid_str = uuid::Uuid::from_slice(&x.clone());
let uuid_str = uuid_str.map(|uuid_str| uuid_str.to_hyphenated().to_string()).unwrap(); let _uuid_str = uuid_str.map(|uuid_str| uuid_str.to_hyphenated().to_string()).unwrap();
let d = DCERPCIface::new(x,i.ver,i.ver_min); let d = DCERPCIface::new(x,i.ver,i.ver_min);
SCLogDebug!("UUID {} version {}/{} bytes {:?}", SCLogDebug!("UUID {} version {}/{} bytes {:?}",
uuid_str, _uuid_str,
i.ver, i.ver_min,i.iface); i.ver, i.ver_min,i.iface);
ifaces.push(d); ifaces.push(d);
} }

@ -251,14 +251,14 @@ fn smb1_request_record_one<'b>(state: &mut SMBState, r: &SmbRecord<'b>, command:
true true
}, },
Err(nom::Err::Incomplete(n)) => { Err(nom::Err::Incomplete(_n)) => {
SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION INCOMPLETE {:?}", n); SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION INCOMPLETE {:?}", _n);
events.push(SMBEvent::MalformedData); events.push(SMBEvent::MalformedData);
false false
}, },
Err(nom::Err::Error(e)) | Err(nom::Err::Error(_e)) |
Err(nom::Err::Failure(e)) => { Err(nom::Err::Failure(_e)) => {
SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION ERROR {:?}", e); SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION ERROR {:?}", _e);
events.push(SMBEvent::MalformedData); events.push(SMBEvent::MalformedData);
false false
}, },
@ -279,14 +279,14 @@ fn smb1_request_record_one<'b>(state: &mut SMBState, r: &SmbRecord<'b>, command:
tx.vercmd.set_smb1_cmd(SMB1_COMMAND_TRANS2); tx.vercmd.set_smb1_cmd(SMB1_COMMAND_TRANS2);
true true
}, },
Err(nom::Err::Incomplete(n)) => { Err(nom::Err::Incomplete(_n)) => {
SCLogDebug!("TRANS2 SET_PATH_INFO DATA RENAME INCOMPLETE {:?}", n); SCLogDebug!("TRANS2 SET_PATH_INFO DATA RENAME INCOMPLETE {:?}", _n);
events.push(SMBEvent::MalformedData); events.push(SMBEvent::MalformedData);
false false
}, },
Err(nom::Err::Error(e)) | Err(nom::Err::Error(_e)) |
Err(nom::Err::Failure(e)) => { Err(nom::Err::Failure(_e)) => {
SCLogDebug!("TRANS2 SET_PATH_INFO DATA RENAME ERROR {:?}", e); SCLogDebug!("TRANS2 SET_PATH_INFO DATA RENAME ERROR {:?}", _e);
events.push(SMBEvent::MalformedData); events.push(SMBEvent::MalformedData);
false false
}, },
@ -295,14 +295,14 @@ fn smb1_request_record_one<'b>(state: &mut SMBState, r: &SmbRecord<'b>, command:
false false
} }
}, },
Err(nom::Err::Incomplete(n)) => { Err(nom::Err::Incomplete(_n)) => {
SCLogDebug!("TRANS2 SET_PATH_INFO PARAMS INCOMPLETE {:?}", n); SCLogDebug!("TRANS2 SET_PATH_INFO PARAMS INCOMPLETE {:?}", _n);
events.push(SMBEvent::MalformedData); events.push(SMBEvent::MalformedData);
false false
}, },
Err(nom::Err::Error(e)) | Err(nom::Err::Error(_e)) |
Err(nom::Err::Failure(e)) => { Err(nom::Err::Failure(_e)) => {
SCLogDebug!("TRANS2 SET_PATH_INFO PARAMS ERROR {:?}", e); SCLogDebug!("TRANS2 SET_PATH_INFO PARAMS ERROR {:?}", _e);
events.push(SMBEvent::MalformedData); events.push(SMBEvent::MalformedData);
false false
}, },
@ -334,14 +334,14 @@ fn smb1_request_record_one<'b>(state: &mut SMBState, r: &SmbRecord<'b>, command:
true true
}, },
Err(nom::Err::Incomplete(n)) => { Err(nom::Err::Incomplete(_n)) => {
SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION INCOMPLETE {:?}", n); SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION INCOMPLETE {:?}", _n);
events.push(SMBEvent::MalformedData); events.push(SMBEvent::MalformedData);
false false
}, },
Err(nom::Err::Error(e)) | Err(nom::Err::Error(_e)) |
Err(nom::Err::Failure(e)) => { Err(nom::Err::Failure(_e)) => {
SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION ERROR {:?}", e); SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION ERROR {:?}", _e);
events.push(SMBEvent::MalformedData); events.push(SMBEvent::MalformedData);
false false
}, },
@ -367,14 +367,14 @@ fn smb1_request_record_one<'b>(state: &mut SMBState, r: &SmbRecord<'b>, command:
tx.vercmd.set_smb1_cmd(SMB1_COMMAND_TRANS2); tx.vercmd.set_smb1_cmd(SMB1_COMMAND_TRANS2);
true true
}, },
Err(nom::Err::Incomplete(n)) => { Err(nom::Err::Incomplete(_n)) => {
SCLogDebug!("TRANS2 SET_FILE_INFO DATA RENAME INCOMPLETE {:?}", n); SCLogDebug!("TRANS2 SET_FILE_INFO DATA RENAME INCOMPLETE {:?}", _n);
events.push(SMBEvent::MalformedData); events.push(SMBEvent::MalformedData);
false false
}, },
Err(nom::Err::Error(e)) | Err(nom::Err::Error(_e)) |
Err(nom::Err::Failure(e)) => { Err(nom::Err::Failure(_e)) => {
SCLogDebug!("TRANS2 SET_FILE_INFO DATA RENAME ERROR {:?}", e); SCLogDebug!("TRANS2 SET_FILE_INFO DATA RENAME ERROR {:?}", _e);
events.push(SMBEvent::MalformedData); events.push(SMBEvent::MalformedData);
false false
}, },
@ -383,14 +383,14 @@ fn smb1_request_record_one<'b>(state: &mut SMBState, r: &SmbRecord<'b>, command:
false false
} }
}, },
Err(nom::Err::Incomplete(n)) => { Err(nom::Err::Incomplete(_n)) => {
SCLogDebug!("TRANS2 SET_FILE_INFO PARAMS INCOMPLETE {:?}", n); SCLogDebug!("TRANS2 SET_FILE_INFO PARAMS INCOMPLETE {:?}", _n);
events.push(SMBEvent::MalformedData); events.push(SMBEvent::MalformedData);
false false
}, },
Err(nom::Err::Error(e)) | Err(nom::Err::Error(_e)) |
Err(nom::Err::Failure(e)) => { Err(nom::Err::Failure(_e)) => {
SCLogDebug!("TRANS2 SET_FILE_INFO PARAMS ERROR {:?}", e); SCLogDebug!("TRANS2 SET_FILE_INFO PARAMS ERROR {:?}", _e);
events.push(SMBEvent::MalformedData); events.push(SMBEvent::MalformedData);
false false
}, },
@ -399,14 +399,14 @@ fn smb1_request_record_one<'b>(state: &mut SMBState, r: &SmbRecord<'b>, command:
false false
} }
}, },
Err(nom::Err::Incomplete(n)) => { Err(nom::Err::Incomplete(_n)) => {
SCLogDebug!("TRANS2 INCOMPLETE {:?}", n); SCLogDebug!("TRANS2 INCOMPLETE {:?}", _n);
events.push(SMBEvent::MalformedData); events.push(SMBEvent::MalformedData);
false false
}, },
Err(nom::Err::Error(e)) | Err(nom::Err::Error(_e)) |
Err(nom::Err::Failure(e)) => { Err(nom::Err::Failure(_e)) => {
SCLogDebug!("TRANS2 ERROR {:?}", e); SCLogDebug!("TRANS2 ERROR {:?}", _e);
events.push(SMBEvent::MalformedData); events.push(SMBEvent::MalformedData);
false false
}, },
@ -883,11 +883,11 @@ pub fn smb1_trans_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>)
let mut frankenfid = pipe.fid.to_vec(); let mut frankenfid = pipe.fid.to_vec();
frankenfid.extend_from_slice(&u32_as_bytes(r.ssn_id)); frankenfid.extend_from_slice(&u32_as_bytes(r.ssn_id));
let (filename, is_dcerpc) = match state.get_service_for_guid(&frankenfid) { let (_filename, is_dcerpc) = match state.get_service_for_guid(&frankenfid) {
(n, x) => (n, x), (n, x) => (n, x),
}; };
SCLogDebug!("smb1_trans_request_record: name {} is_dcerpc {}", SCLogDebug!("smb1_trans_request_record: name {} is_dcerpc {}",
filename, is_dcerpc); _filename, is_dcerpc);
pipe_dcerpc = is_dcerpc; pipe_dcerpc = is_dcerpc;
} }
@ -924,11 +924,11 @@ pub fn smb1_trans_response_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>)
let mut frankenfid = fid.to_vec(); let mut frankenfid = fid.to_vec();
frankenfid.extend_from_slice(&u32_as_bytes(r.ssn_id)); frankenfid.extend_from_slice(&u32_as_bytes(r.ssn_id));
let (filename, is_dcerpc) = match state.get_service_for_guid(&frankenfid) { let (_filename, is_dcerpc) = match state.get_service_for_guid(&frankenfid) {
(n, x) => (n, x), (n, x) => (n, x),
}; };
SCLogDebug!("smb1_trans_response_record: name {} is_dcerpc {}", SCLogDebug!("smb1_trans_response_record: name {} is_dcerpc {}",
filename, is_dcerpc); _filename, is_dcerpc);
// if we get status 'BUFFER_OVERFLOW' this is only a part of // if we get status 'BUFFER_OVERFLOW' this is only a part of
// the data. Store it in the ssn/tree for later use. // the data. Store it in the ssn/tree for later use.

@ -579,20 +579,20 @@ pub fn smb2_response_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
if r.nt_status == SMB_NTSTATUS_SUCCESS { if r.nt_status == SMB_NTSTATUS_SUCCESS {
match parse_smb2_response_write(r.data) match parse_smb2_response_write(r.data)
{ {
Ok((_, wr)) => { Ok((_, _wr)) => {
SCLogDebug!("SMBv2: Write response => {:?}", wr); SCLogDebug!("SMBv2: Write response => {:?}", _wr);
/* search key-guid map */ /* search key-guid map */
let guid_key = SMBCommonHdr::new(SMBHDR_TYPE_GUID, let guid_key = SMBCommonHdr::new(SMBHDR_TYPE_GUID,
r.session_id, r.tree_id, r.message_id); r.session_id, r.tree_id, r.message_id);
let guid_vec = match state.ssn2vec_map.remove(&guid_key) { let _guid_vec = match state.ssn2vec_map.remove(&guid_key) {
Some(p) => p, Some(p) => p,
None => { None => {
SCLogDebug!("SMBv2 response: GUID NOT FOUND"); SCLogDebug!("SMBv2 response: GUID NOT FOUND");
Vec::new() Vec::new()
}, },
}; };
SCLogDebug!("SMBv2 write response for GUID {:?}", guid_vec); SCLogDebug!("SMBv2 write response for GUID {:?}", _guid_vec);
} }
_ => { _ => {
events.push(SMBEvent::MalformedData); events.push(SMBEvent::MalformedData);

@ -20,6 +20,7 @@ use crate::smb::smb2::*;
use crate::smb::smb2_records::*; use crate::smb::smb2_records::*;
use crate::smb::dcerpc::*; use crate::smb::dcerpc::*;
use crate::smb::events::*; use crate::smb::events::*;
#[cfg(feature = "debug")]
use crate::smb::funcs::*; use crate::smb::funcs::*;
#[derive(Debug)] #[derive(Debug)]

@ -195,8 +195,8 @@ impl<'a> SNMPState<'a> {
Ok((_rem,SnmpGenericMessage::V1(msg))) | Ok((_rem,SnmpGenericMessage::V1(msg))) |
Ok((_rem,SnmpGenericMessage::V2(msg))) => self.handle_snmp_v12(msg, direction), Ok((_rem,SnmpGenericMessage::V2(msg))) => self.handle_snmp_v12(msg, direction),
Ok((_rem,SnmpGenericMessage::V3(msg))) => self.handle_snmp_v3(msg, direction), Ok((_rem,SnmpGenericMessage::V3(msg))) => self.handle_snmp_v3(msg, direction),
Err(e) => { Err(_e) => {
SCLogDebug!("parse_snmp failed: {:?}", e); SCLogDebug!("parse_snmp failed: {:?}", _e);
self.set_event(SNMPEvent::MalformedData); self.set_event(SNMPEvent::MalformedData);
-1 -1
}, },

@ -256,15 +256,15 @@ impl SSHState {
panic!("SSH invalid length record header"); panic!("SSH invalid length record header");
} }
} }
Err(e) => { Err(_e) => {
SCLogDebug!("SSH invalid record header {}", e); SCLogDebug!("SSH invalid record header {}", _e);
self.set_event(SSHEvent::InvalidRecord); self.set_event(SSHEvent::InvalidRecord);
return AppLayerResult::err(); return AppLayerResult::err();
} }
} }
} }
Err(e) => { Err(_e) => {
SCLogDebug!("SSH invalid record {}", e); SCLogDebug!("SSH invalid record {}", _e);
self.set_event(SSHEvent::InvalidRecord); self.set_event(SSHEvent::InvalidRecord);
return AppLayerResult::err(); return AppLayerResult::err();
} }
@ -294,8 +294,8 @@ impl SSHState {
Err(nom::Err::Incomplete(_)) => { Err(nom::Err::Incomplete(_)) => {
return AppLayerResult::incomplete(0 as u32, (input.len() + 1) as u32); return AppLayerResult::incomplete(0 as u32, (input.len() + 1) as u32);
} }
Err(e) => { Err(_e) => {
SCLogDebug!("SSH invalid banner {}", e); SCLogDebug!("SSH invalid banner {}", _e);
self.set_event(SSHEvent::InvalidBanner); self.set_event(SSHEvent::InvalidBanner);
return AppLayerResult::err(); return AppLayerResult::err();
} }
@ -353,8 +353,8 @@ impl SSHState {
} }
} }
} }
Err(e) => { Err(_e) => {
SCLogDebug!("SSH invalid banner {}", e); SCLogDebug!("SSH invalid banner {}", _e);
self.set_event(SSHEvent::InvalidBanner); self.set_event(SSHEvent::InvalidBanner);
return AppLayerResult::err(); return AppLayerResult::err();
} }

Loading…
Cancel
Save