From: Philippe Antoine Date: Wed, 26 May 2021 18:54:01 +0000 (+0200) Subject: http2: turn Host header into authority during upgrade X-Git-Tag: suricata-6.0.4~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59a109c0495ecb7351b7a6df7ae1f8f8f97f02e1;p=thirdparty%2Fsuricata.git http2: turn Host header into authority during upgrade HTTP1 uses Host, but HTTP2 uses rather :authority cf HPACK (cherry picked from commit 75f75e1eb09c208a42e58b2babbc55027cd79e28) --- diff --git a/rust/src/http2/detect.rs b/rust/src/http2/detect.rs index da572dfbd8..b374a16999 100644 --- a/rust/src/http2/detect.rs +++ b/rust/src/http2/detect.rs @@ -866,6 +866,13 @@ fn http2_tx_set_settings(state: &mut HTTP2State, input: &[u8]) { } } +fn http2_caseinsensitive_cmp(s1: &[u8], s2: &str) -> bool { + if let Ok(s) = std::str::from_utf8(s1) { + return s.to_lowercase() == s2; + } + return false; +} + #[no_mangle] pub extern "C" fn rs_http2_tx_add_header( state: &mut HTTP2State, name: *const u8, name_len: u32, value: *const u8, value_len: u32, @@ -874,6 +881,8 @@ pub extern "C" fn rs_http2_tx_add_header( let slice_value = build_slice!(value, value_len as usize); if slice_name == "HTTP2-Settings".as_bytes() { http2_tx_set_settings(state, slice_value) + } else if http2_caseinsensitive_cmp(slice_name, "host") { + http2_tx_set_header(state, ":authority".as_bytes(), slice_value) } else { http2_tx_set_header(state, slice_name, slice_value) }