smb: prevents integer underflow

Ticket: 5246

If msg_id is 0, we cannot find the previous request
pull/7230/head
Philippe Antoine 3 years ago committed by Victor Julien
parent e72036f12f
commit 3e48881b78

@ -376,10 +376,14 @@ pub fn smb2_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
None => { None => {
// try to find latest created file in case of chained commands // try to find latest created file in case of chained commands
let mut guid_key = SMBCommonHdr::from2(r, SMBHDR_TYPE_FILENAME); let mut guid_key = SMBCommonHdr::from2(r, SMBHDR_TYPE_FILENAME);
guid_key.msg_id = guid_key.msg_id - 1; if guid_key.msg_id == 0 {
match state.ssn2vec_map.get(&guid_key) { b"<unknown>".to_vec()
Some(n) => { n.to_vec() }, } else {
None => { b"<unknown>".to_vec()}, guid_key.msg_id = guid_key.msg_id - 1;
match state.ssn2vec_map.get(&guid_key) {
Some(n) => { n.to_vec() },
None => { b"<unknown>".to_vec()},
}
} }
}, },
}; };

Loading…
Cancel
Save