From: Philippe Antoine Date: Sun, 24 Jul 2022 19:54:24 +0000 (+0200) Subject: http2: remove to_vec for comparisons X-Git-Tag: suricata-6.0.7~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16da02cfbd93ac14053012d78ad04f2c6a40abd5;p=thirdparty%2Fsuricata.git http2: remove to_vec for comparisons Ticket: #5454 (cherry picked from commit 9b4a133777e8d25eda0f9f44095bc4a10d8cce21) Conflict fixed by Philippe Antoine --- diff --git a/rust/src/http2/decompression.rs b/rust/src/http2/decompression.rs index f158785e87..67f46cc634 100644 --- a/rust/src/http2/decompression.rs +++ b/rust/src/http2/decompression.rs @@ -168,13 +168,13 @@ impl HTTP2DecoderHalf { pub fn http2_encoding_fromvec(&mut self, input: &[u8]) { //use first encoding... if self.encoding == HTTP2ContentEncoding::HTTP2ContentEncodingUnknown { - if *input == "gzip".as_bytes().to_vec() { + if input == b"gzip" { self.encoding = HTTP2ContentEncoding::HTTP2ContentEncodingGzip; self.decoder = HTTP2Decompresser::GZIP(GzDecoder::new(HTTP2cursor::new())); - } else if *input == "deflate".as_bytes().to_vec() { + } else if input == b"deflate" { self.encoding = HTTP2ContentEncoding::HTTP2ContentEncodingDeflate; self.decoder = HTTP2Decompresser::DEFLATE(DeflateDecoder::new(HTTP2cursor::new())); - } else if *input == "br".as_bytes().to_vec() { + } else if input == b"br" { self.encoding = HTTP2ContentEncoding::HTTP2ContentEncodingBr; self.decoder = HTTP2Decompresser::BROTLI(brotli::Decompressor::new( HTTP2cursor::new(), diff --git a/rust/src/http2/detect.rs b/rust/src/http2/detect.rs index 24436843ed..8a7300ac3b 100644 --- a/rust/src/http2/detect.rs +++ b/rust/src/http2/detect.rs @@ -489,7 +489,7 @@ fn http2_frames_get_header_firstvalue<'a>( for i in 0..frames.len() { if let Some(blocks) = http2_header_blocks(&frames[i]) { for block in blocks.iter() { - if block.name == name.as_bytes().to_vec() { + if block.name == name.as_bytes() { return Ok(&block.value); } } @@ -512,7 +512,7 @@ fn http2_frames_get_header_value<'a>( for i in 0..frames.len() { if let Some(blocks) = http2_header_blocks(&frames[i]) { for block in blocks.iter() { - if block.name == name.as_bytes().to_vec() { + if block.name == name.as_bytes() { if found == 0 { single = Ok(&block.value); found = 1; diff --git a/rust/src/http2/http2.rs b/rust/src/http2/http2.rs index 6536d4141a..c9aee2c969 100644 --- a/rust/src/http2/http2.rs +++ b/rust/src/http2/http2.rs @@ -180,7 +180,7 @@ impl HTTP2Transaction { #[cfg(feature = "decompression")] fn handle_headers(&mut self, blocks: &Vec, dir: u8) { for i in 0..blocks.len() { - if blocks[i].name == "content-encoding".as_bytes().to_vec() { + if blocks[i].name == b"content-encoding" { self.decoder.http2_encoding_fromvec(&blocks[i].value, dir); } }