From 2fec7251bef908c667a6a060ee7bd2f53f7da88e Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Thu, 9 Dec 2021 06:32:14 -0500 Subject: [PATCH] CVE-2021-44716 Origin: backport, https://github.com/golang/go/commit/48d94896 Gbp-Pq: Name 0010-CVE-2021-44716.patch --- src/net/http/h2_bundle.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go index 3d830847..06f8808d 100644 --- a/src/net/http/h2_bundle.go +++ b/src/net/http/h2_bundle.go @@ -4289,7 +4289,15 @@ func (sc *http2serverConn) canonicalHeader(v string) string { sc.canonHeader = make(map[string]string) } cv = CanonicalHeaderKey(v) - sc.canonHeader[v] = cv + // maxCachedCanonicalHeaders is an arbitrarily-chosen limit on the number of + // entries in the canonHeader cache. This should be larger than the number + // of unique, uncommon header keys likely to be sent by the peer, while not + // so high as to permit unreaasonable memory usage if the peer sends an unbounded + // number of unique header keys. + const maxCachedCanonicalHeaders = 32 + if len(sc.canonHeader) < maxCachedCanonicalHeaders { + sc.canonHeader[v] = cv + } return cv } -- 2.30.2