From: Philippe Antoine Date: Mon, 21 Nov 2022 16:06:44 +0000 (+0100) Subject: http2: fix decompression buffering X-Git-Tag: suricata-6.0.9~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0324a9b20b089038d789c1b1388b2ec79e7893dd;p=thirdparty%2Fsuricata.git http2: fix decompression buffering 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) --- diff --git a/rust/src/http2/decompression.rs b/rust/src/http2/decompression.rs index 67f46cc634..6848a05ab3 100644 --- a/rust/src/http2/decompression.rs +++ b/rust/src/http2/decompression.rs @@ -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]); }