]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.18] net/http: update bundled golang.org/x/net/http2
authorDamien Neil <dneil@google.com>
Wed, 30 Nov 2022 21:37:07 +0000 (16:37 -0500)
committerJenny Rakoczy <jenny@golang.org>
Tue, 6 Dec 2022 19:00:28 +0000 (19:00 +0000)
Disable cmd/internal/moddeps test, since this update includes PRIVATE
track fixes.

For #56350
For #57008
Fixes CVE-2022-41717

Change-Id: I31ebd2b9ae190ef6f7646187103ea1c8a713ff2e
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1663833
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/455361
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/internal/moddeps/moddeps_test.go
src/net/http/h2_bundle.go

index 56c3b2585c7fdc211a0c4e17827bf182eb938661..cd4d523e464219b8b515b124ef3dbdf6d4b95c90 100644 (file)
@@ -34,6 +34,8 @@ import (
 // See issues 36852, 41409, and 43687.
 // (Also see golang.org/issue/27348.)
 func TestAllDependencies(t *testing.T) {
+       t.Skip("TODO(#57008): 1.18.9 contains unreleased changes from vendored modules")
+
        goBin := testenv.GoToolPath(t)
 
        // Ensure that all packages imported within GOROOT
index 292dded28ddb3750cb819154bf0379be53317dc4..381f91c8ad983b52044f0e117cb39038013a5713 100644 (file)
@@ -3384,10 +3384,11 @@ func (s http2SettingID) String() string {
 // name (key). See httpguts.ValidHeaderName for the base rules.
 //
 // Further, http2 says:
-//   "Just as in HTTP/1.x, header field names are strings of ASCII
-//   characters that are compared in a case-insensitive
-//   fashion. However, header field names MUST be converted to
-//   lowercase prior to their encoding in HTTP/2. "
+//
+//     "Just as in HTTP/1.x, header field names are strings of ASCII
+//     characters that are compared in a case-insensitive
+//     fashion. However, header field names MUST be converted to
+//     lowercase prior to their encoding in HTTP/2. "
 func http2validWireHeaderFieldName(v string) bool {
        if len(v) == 0 {
                return false
@@ -3578,8 +3579,8 @@ func (s *http2sorter) SortStrings(ss []string) {
 // validPseudoPath reports whether v is a valid :path pseudo-header
 // value. It must be either:
 //
-//     *) a non-empty string starting with '/'
-//     *) the string '*', for OPTIONS requests.
+//     *) a non-empty string starting with '/'
+//     *) the string '*', for OPTIONS requests.
 //
 // For now this is only used a quick check for deciding when to clean
 // up Opaque URLs before sending requests from the Transport.
@@ -4242,6 +4243,7 @@ type http2serverConn struct {
        headerTableSize             uint32
        peerMaxHeaderListSize       uint32            // zero means unknown (default)
        canonHeader                 map[string]string // http2-lower-case -> Go-Canonical-Case
+       canonHeaderKeysSize         int               // canonHeader keys size in bytes
        writingFrame                bool              // started writing a frame (on serve goroutine or separate)
        writingFrameAsync           bool              // started a frame on its own goroutine but haven't heard back on wroteFrameCh
        needsFrameFlush             bool              // last frame write wasn't a flush
@@ -4421,6 +4423,13 @@ func (sc *http2serverConn) condlogf(err error, format string, args ...interface{
        }
 }
 
+// maxCachedCanonicalHeadersKeysSize is an arbitrarily-chosen limit on the size
+// of the entries in the canonHeader cache.
+// This should be larger than the size of unique, uncommon header keys likely to
+// be sent by the peer, while not so high as to permit unreasonable memory usage
+// if the peer sends an unbounded number of unique header keys.
+const http2maxCachedCanonicalHeadersKeysSize = 2048
+
 func (sc *http2serverConn) canonicalHeader(v string) string {
        sc.serveG.check()
        http2buildCommonHeaderMapsOnce()
@@ -4436,14 +4445,10 @@ func (sc *http2serverConn) canonicalHeader(v string) string {
                sc.canonHeader = make(map[string]string)
        }
        cv = CanonicalHeaderKey(v)
-       // 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 {
+       size := 100 + len(v)*2 // 100 bytes of map overhead + key + value
+       if sc.canonHeaderKeysSize+size <= http2maxCachedCanonicalHeadersKeysSize {
                sc.canonHeader[v] = cv
+               sc.canonHeaderKeysSize += size
        }
        return cv
 }