]> 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 13:06:47 +0000 (15:06 +0200)
Ticket: 7104

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

(cherry picked from commit 5bd17934df321b88f502d48afdd6cc8bad4787a7)

rust/src/http2/detect.rs

index 9e3a5ef63a040ee5d4e880a545b862cb38e62f51..726b19e7edd8e62a38ae80728bb499210d46b8e4 100644 (file)
@@ -517,14 +517,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);
                     }