]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http2: have filecontainer for both directions
authorPhilippe Antoine <contact@catenacyber.fr>
Fri, 23 Apr 2021 19:55:20 +0000 (21:55 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 7 Jun 2021 08:58:05 +0000 (10:58 +0200)
(cherry picked from commit 6fe8bce3b0c653df8e72bdb81bc235672386b8b1)

rust/src/http2/http2.rs

index a726bfeff4e9aba4a1c19939c11900ceed310ee4..a3277d10b9ef559f4334a393da5876de4ec9d15e 100644 (file)
@@ -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)
@@ -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),
         }
     }
@@ -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(());
     }
 
@@ -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],