From 9fec31fb0fd49a4671004596e610debeda36a62c Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 25 Jan 2018 10:05:55 +0100 Subject: [PATCH] rust/file: handle file open errors --- rust/src/filetracker.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/rust/src/filetracker.rs b/rust/src/filetracker.rs index 0bfe1a7077..b1b7a4d5df 100644 --- a/rust/src/filetracker.rs +++ b/rust/src/filetracker.rs @@ -95,8 +95,8 @@ impl FileTransferTracker { let r = files.file_open(config, &self.track_id, name, flags); if r == 0 { files.file_set_txid_on_last_file(self.tx_id); + self.file_open = true; } - self.file_open = true; r } @@ -110,7 +110,7 @@ impl FileTransferTracker { } pub fn trunc (&mut self, files: &mut FileContainer, flags: u16) { - if self.file_is_truncated { + if self.file_is_truncated || !self.file_open { return; } let myflags = flags | 1; // TODO util-file.c::FILE_TRUNCATED @@ -159,9 +159,13 @@ impl FileTransferTracker { self.open(config, files, flags, name); } - let res = self.update(files, flags, data, 0); - SCLogDebug!("NEW CHUNK: update res {:?}", res); - res + if self.file_open == true { + let res = self.update(files, flags, data, 0); + SCLogDebug!("NEW CHUNK: update res {:?}", res); + return res; + } + + 0 } /// update the file tracker -- 2.47.2