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 => {
// try to find latest created file in case of chained commands
let mut guid_key = SMBCommonHdr::from2(r, SMBHDR_TYPE_FILENAME);
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()},
if guid_key.msg_id == 0 {
b"<unknown>".to_vec()
} else {
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