]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/filetracker: remove reachable panic 3561/head
authorVictor Julien <victor@inliniac.net>
Fri, 30 Nov 2018 10:59:17 +0000 (11:59 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 30 Nov 2018 11:00:06 +0000 (12:00 +0100)
Remove reachable panic condition when an existing file chunk is not
completed. Instead trunc the file and reset.

Related to bug #2717

rust/src/filetracker.rs

index e393a8bbf2fc58cd77cabc7a6a79e7c2655e7a08..3b2f73634405fb9e9c2d7584f52b5ce6f83017f0 100644 (file)
@@ -136,8 +136,10 @@ impl FileTransferTracker {
             name: &[u8], data: &[u8], chunk_offset: u64, chunk_size: u32,
             fill_bytes: u8, is_last: bool, xid: &u32) -> u32
     {
-        if self.chunk_left != 0 { panic!("complete existing chunk first"); }
-        if self.fill_bytes != 0 { panic!("complete existing fill bytes first"); }
+        if self.chunk_left != 0 || self.fill_bytes != 0 {
+            SCLogDebug!("current chunk incomplete: truncating");
+            self.trunc(files, flags);
+        }
 
         SCLogDebug!("NEW CHUNK: chunk_size {} fill_bytes {}", chunk_size, fill_bytes);