]> 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>
Fri, 25 Nov 2022 19:12:31 +0000 (20:12 +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
(cherry picked from commit 086b28da3d06b269ba23ff0fa3c99419ce2f4d6a)

rust/src/http2/decompression.rs

index 67f46cc634a9005239156a54cbe511d17c0b30ec..6848a05ab3dab26e94c6d2c1ee3dccbde439f27f 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
@@ -152,8 +157,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]);
 }