rust/smb: avoid allocation in smb status function

Avoid an allocation by returning a static string.
pull/7959/head
Eric Leblond 4 years ago committed by Victor Julien
parent 9cb06d4376
commit a9519778de

@ -99,7 +99,13 @@ fn smb_common_header(jsb: &mut JsonBuilder, state: &SMBState, tx: &SMBTransactio
match tx.vercmd.get_ntstatus() {
(true, ntstatus) => {
let status = smb_ntstatus_string(ntstatus);
jsb.set_string("status", &status)?;
match status {
Some(x) => jsb.set_string("status", &x)?,
None => {
let status_str = format!("{}", ntstatus);
jsb.set_string("status", &status_str)?
},
};
let status_hex = format!("0x{:x}", ntstatus);
jsb.set_string("status_code", &status_hex)?;
},

@ -649,7 +649,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>)
{
SCLogDebug!("SMBv2 response record, command {} status {} tree {} session {} message {}",
&smb2_command_string(r.command), &smb_ntstatus_string(r.nt_status),
&smb2_command_string(r.command), r.nt_status,
r.tree_id, r.session_id, r.message_id);
let mut events : Vec<SMBEvent> = Vec::new();
@ -725,7 +725,7 @@ pub fn smb2_response_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
}
false
} else {
SCLogDebug!("SMBv2 READ: status {}", &smb_ntstatus_string(r.nt_status));
SCLogDebug!("SMBv2 READ: status {}", r.nt_status);
false
}
},

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save