diff --git a/rust/src/filetracker.rs b/rust/src/filetracker.rs index 4585608d9b..dbc80a682e 100644 --- a/rust/src/filetracker.rs +++ b/rust/src/filetracker.rs @@ -85,6 +85,10 @@ impl FileTransferTracker { !self.file_open } + pub fn is_initialized(&self) -> bool { + return self.file_open || self.file_is_truncated; + } + fn open(&mut self, config: &'static SuricataFileContext, name: &[u8]) -> i32 { let r = self.file.file_open(config, self.track_id, name, self.file_flags); diff --git a/rust/src/http2/http2.rs b/rust/src/http2/http2.rs index 63032cc5b6..a24b8a0581 100644 --- a/rust/src/http2/http2.rs +++ b/rust/src/http2/http2.rs @@ -219,7 +219,8 @@ impl HTTP2Transaction { let xid: u32 = self.tx_id as u32; if dir == Direction::ToClient { self.ft_tc.tx_id = self.tx_id - 1; - if !self.ft_tc.file_open { + // Check that we are at the beginning of the file + if !self.ft_tc.is_initialized() { // we are now sure that new_chunk will open a file // even if it may close it right afterwards self.tx_data.incr_files_opened();