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,11 +376,15 @@ 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);
if guid_key.msg_id == 0 {
b"<unknown>".to_vec()
} else {
guid_key.msg_id = guid_key.msg_id - 1; guid_key.msg_id = guid_key.msg_id - 1;
match state.ssn2vec_map.get(&guid_key) { match state.ssn2vec_map.get(&guid_key) {
Some(n) => { n.to_vec() }, Some(n) => { n.to_vec() },
None => { b"<unknown>".to_vec()}, None => { b"<unknown>".to_vec()},
} }
}
}, },
}; };
let tx = state.new_setfileinfo_tx(fname, rd.guid.to_vec(), rd.class as u16, rd.infolvl as u16, dis.delete); let tx = state.new_setfileinfo_tx(fname, rd.guid.to_vec(), rd.class as u16, rd.infolvl as u16, dis.delete);

Loading…
Cancel
Save