Skip to content

Commit

Permalink
http2: have filecontainer for both directions
Browse files Browse the repository at this point in the history
(cherry picked from commit 6fe8bce)
  • Loading branch information
catenacyber authored and victorjulien committed Jun 7, 2021
1 parent 2504b96 commit 56bda0f
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions rust/src/http2/http2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ pub struct HTTP2Transaction {
de_state: Option<*mut core::DetectEngineState>,
events: *mut core::AppLayerDecoderEvents,
tx_data: AppLayerTxData,
ft: FileTransferTracker,
ft_tc: FileTransferTracker,
ft_ts: FileTransferTracker,

//temporary escaped header for detection
//must be attached to transaction for memory management (be freed at the right time)
Expand All @@ -152,7 +153,8 @@ impl HTTP2Transaction {
de_state: None,
events: std::ptr::null_mut(),
tx_data: AppLayerTxData::new(),
ft: FileTransferTracker::new(),
ft_tc: FileTransferTracker::new(),
ft_ts: FileTransferTracker::new(),
escaped: Vec::with_capacity(16),
}
}
Expand Down Expand Up @@ -181,18 +183,33 @@ impl HTTP2Transaction {
let mut output = Vec::with_capacity(decompression::HTTP2_DECOMPRESSION_CHUNK_SIZE);
let decompressed = self.decoder.decompress(input, &mut output, dir)?;
let xid: u32 = self.tx_id as u32;
self.ft.new_chunk(
sfcm,
files,
flags,
b"",
decompressed,
self.ft.tracked, //offset = append
decompressed.len() as u32,
0,
over,
&xid,
);
if dir == STREAM_TOCLIENT {
self.ft_tc.new_chunk(
sfcm,
files,
flags,
b"",
decompressed,
self.ft_tc.tracked, //offset = append
decompressed.len() as u32,
0,
over,
&xid,
);
} else {
self.ft_ts.new_chunk(
sfcm,
files,
flags,
b"",
decompressed,
self.ft_ts.tracked, //offset = append
decompressed.len() as u32,
0,
over,
&xid,
);
};
return Ok(());
}

Expand Down Expand Up @@ -808,7 +825,11 @@ impl HTTP2State {
let index = self.find_tx_index(sid);
if index > 0 {
let mut tx_same = &mut self.transactions[index - 1];
tx_same.ft.tx_id = tx_same.tx_id - 1;
if dir == STREAM_TOCLIENT {
tx_same.ft_tc.tx_id = tx_same.tx_id - 1;
} else {
tx_same.ft_ts.tx_id = tx_same.tx_id - 1;
}
let (files, flags) = self.files.get(dir);
match tx_same.decompress(
&rem[..hlsafe],
Expand Down

0 comments on commit 56bda0f

Please sign in to comment.