]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
nfs: fix integer underflow
authorVictor Julien <victor@inliniac.net>
Tue, 2 Apr 2019 13:32:33 +0000 (15:32 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 30 Apr 2019 09:12:28 +0000 (11:12 +0200)
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

index 3170d16a9e821284bfe77d0597e1815462619319..96f1171fb4bc451b74bcdf1351be8a3deaaff60c 100644 (file)
@@ -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) {