Skip to content

Commit ba99241

Browse files
catenacybervictorjulien
authored andcommitted
http2: fix leak with range files
Ticket: OISF#5808 May have been introduced by a24d7dc Function http2_range_open expects to be called only when tx.file_range is nil. One condition to ensure this is to check that we are beginning the files contents. The filetracker field file_open is not fit for this, as it may be reset to false.
1 parent a0fc00b commit ba99241

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

rust/src/filetracker.rs

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ impl FileTransferTracker {
8585
!self.file_open
8686
}
8787

88+
pub fn is_initialized(&self) -> bool {
89+
return self.file_open || self.file_is_truncated;
90+
}
91+
8892
fn open(&mut self, config: &'static SuricataFileContext, name: &[u8]) -> i32
8993
{
9094
let r = self.file.file_open(config, self.track_id, name, self.file_flags);

rust/src/http2/http2.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ impl HTTP2Transaction {
219219
let xid: u32 = self.tx_id as u32;
220220
if dir == Direction::ToClient {
221221
self.ft_tc.tx_id = self.tx_id - 1;
222-
if !self.ft_tc.file_open {
222+
// Check that we are at the beginning of the file
223+
if !self.ft_tc.is_initialized() {
223224
// we are now sure that new_chunk will open a file
224225
// even if it may close it right afterwards
225226
self.tx_data.incr_files_opened();

0 commit comments

Comments
 (0)