From eedf08be2983e166180b816c45a309e65c88ed88 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 30 Nov 2018 11:59:17 +0100 Subject: [PATCH] rust/filetracker: remove reachable panic 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rust/src/filetracker.rs b/rust/src/filetracker.rs index e393a8bbf2..3b2f736344 100644 --- a/rust/src/filetracker.rs +++ b/rust/src/filetracker.rs @@ -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); -- 2.47.2