From 63ab296cca7d2341b3ef587a3413e562c52cbee2 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 2 Apr 2019 15:32:33 +0200 Subject: [PATCH] nfs: fix integer underflow MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fix int underflow that leads to Rust panic in NFS3 readdirplus parsing. Reported-by: Sirko Höer -- Code Intelligence for DCSO. --- rust/src/nfs/nfs3.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) { -- 2.47.3