From: Victor Julien Date: Fri, 30 Nov 2018 10:59:17 +0000 (+0100) Subject: rust/filetracker: remove reachable panic X-Git-Tag: suricata-4.1.1~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3561%2Fhead;p=thirdparty%2Fsuricata.git 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 --- 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);