]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http2: do not expand duplicate headers
authorPhilippe Antoine <pantoine@oisf.net>
Mon, 17 Jun 2024 14:30:49 +0000 (16:30 +0200)
committerVictor Julien <vjulien@oisf.net>
Tue, 25 Jun 2024 09:34:17 +0000 (11:34 +0200)
Ticket: 7104

As this can cause a big mamory allocation due to the quadratic
nature of the HPACK compression.

rust/src/http2/detect.rs

index 67933b6c24461e0721ae0bf8da0bb853693fc6eb..0e7cee87573d13fdfae7cca78115e12bae0a8159 100644 (file)
@@ -433,11 +433,11 @@ pub fn http2_frames_get_header_value_vec(
                     if found == 0 {
                         vec.extend_from_slice(&block.value);
                         found = 1;
-                    } else if found == 1 {
+                    } else if found == 1 && Rc::strong_count(&block.name) <= 2 {
                         vec.extend_from_slice(&[b',', b' ']);
                         vec.extend_from_slice(&block.value);
                         found = 2;
-                    } else {
+                    } else if Rc::strong_count(&block.name) <= 2 {
                         vec.extend_from_slice(&[b',', b' ']);
                         vec.extend_from_slice(&block.value);
                     }
@@ -470,14 +470,14 @@ fn http2_frames_get_header_value<'a>(
                     if found == 0 {
                         single = Ok(&block.value);
                         found = 1;
-                    } else if found == 1 {
+                    } else if found == 1 && Rc::strong_count(&block.name) <= 2 {
                         if let Ok(s) = single {
                             vec.extend_from_slice(s);
                         }
                         vec.extend_from_slice(&[b',', b' ']);
                         vec.extend_from_slice(&block.value);
                         found = 2;
-                    } else {
+                    } else if Rc::strong_count(&block.name) <= 2 {
                         vec.extend_from_slice(&[b',', b' ']);
                         vec.extend_from_slice(&block.value);
                     }