From: Victor Julien Date: Tue, 2 Apr 2019 13:32:33 +0000 (+0200) Subject: nfs: fix integer underflow X-Git-Tag: suricata-5.0.0-beta1~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63ab296cca7d2341b3ef587a3413e562c52cbee2;p=thirdparty%2Fsuricata.git nfs: fix integer underflow Fix int underflow that leads to Rust panic in NFS3 readdirplus parsing. Reported-by: Sirko Höer -- Code Intelligence for DCSO. --- diff --git a/rust/src/nfs/nfs3.rs b/rust/src/nfs/nfs3.rs index 3170d16a9e..96f1171fb4 100644 --- a/rust/src/nfs/nfs3.rs +++ b/rust/src/nfs/nfs3.rs @@ -286,7 +286,11 @@ impl NFSState { nfs_status = reply.status; // cut off final eof field - let d = &reply.data[..reply.data.len()-4 as usize]; + let d = if reply.data.len() >= 4 { + &reply.data[..reply.data.len()-4 as usize] + } else { + reply.data + }; // store all handle/filename mappings match many0_nfs3_response_readdirplus_entries(d) {