]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http2: fix decompression buffering
authorPhilippe Antoine <pantoine@oisf.net>
Mon, 21 Nov 2022 16:06:44 +0000 (17:06 +0100)
committerVictor Julien <vjulien@oisf.net>
Tue, 22 Nov 2022 13:20:20 +0000 (14:20 +0100)
It was not enough to set Cursor position to 0,
also its inner Vec should be cleared.

This way, a new input gets written at the beginning of the
Cursor and its inner Vec...

Ticket: #5691

rust/src/http2/decompression.rs

index df94d20690a3061ac4d29304dc4df0986b3bbb8e..9356834f2dd6faacedddf0f03c9b0c761913d5d2 100644 (file)
@@ -50,6 +50,11 @@ impl HTTP2cursor {
     pub fn set_position(&mut self, pos: u64) {
         return self.cursor.set_position(pos);
     }
+
+    pub fn clear(&mut self) {
+        self.cursor.get_mut().clear();
+        self.cursor.set_position(0);
+    }
 }
 
 // we need to implement this as flate2 and brotli crates
@@ -156,8 +161,7 @@ fn http2_decompress<'a>(
         }
     }
     //brotli does not consume all input if it reaches some end
-
-    decoder.get_mut().set_position(0);
+    decoder.get_mut().clear();
     return Ok(&output[..offset]);
 }