xref: /OK3568_Linux_fs/yocto/poky/meta/recipes-devtools/go/go-1.18/CVE-2022-27664.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunFrom 5bc9106458fc07851ac324a4157132a91b1f3479 Mon Sep 17 00:00:00 2001
2*4882a593SmuzhiyunFrom: Damien Neil <dneil@google.com>
3*4882a593SmuzhiyunDate: Mon, 22 Aug 2022 16:21:02 -0700
4*4882a593SmuzhiyunSubject: [PATCH] [release-branch.go1.18] net/http: update bundled
5*4882a593Smuzhiyun golang.org/x/net/http2
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunDisable cmd/internal/moddeps test, since this update includes PRIVATE
8*4882a593Smuzhiyuntrack fixes.
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunFixes CVE-2022-27664
11*4882a593SmuzhiyunFixes #53977
12*4882a593SmuzhiyunFor #54658.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunChange-Id: I84b0b8f61e49e15ef55ef8d738730107a3cf849b
15*4882a593SmuzhiyunReviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1554415
16*4882a593SmuzhiyunReviewed-by: Roland Shoemaker <bracewell@google.com>
17*4882a593SmuzhiyunReviewed-by: Tatiana Bradley <tatianabradley@google.com>
18*4882a593SmuzhiyunReviewed-on: https://go-review.googlesource.com/c/go/+/428635
19*4882a593SmuzhiyunReviewed-by: Tatiana Bradley <tatiana@golang.org>
20*4882a593SmuzhiyunRun-TryBot: Michael Knyszek <mknyszek@google.com>
21*4882a593SmuzhiyunTryBot-Result: Gopher Robot <gobot@golang.org>
22*4882a593SmuzhiyunReviewed-by: Carlos Amedee <carlos@golang.org>
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunUpstream-Status: Backport
25*4882a593SmuzhiyunCVE: CVE-2022-27664
26*4882a593Smuzhiyun
27*4882a593SmuzhiyunReference to upstream patch: https://github.com/golang/go/commit/5bc9106458fc07851ac324a4157132a91b1f3479
28*4882a593SmuzhiyunSigned-off-by: Teoh Jay Shen <jay.shen.teoh@intel.com>
29*4882a593Smuzhiyun---
30*4882a593Smuzhiyun src/cmd/internal/moddeps/moddeps_test.go |  2 ++
31*4882a593Smuzhiyun src/net/http/h2_bundle.go                | 21 +++++++++++++--------
32*4882a593Smuzhiyun 2 files changed, 15 insertions(+), 8 deletions(-)
33*4882a593Smuzhiyun
34*4882a593Smuzhiyundiff --git a/src/cmd/internal/moddeps/moddeps_test.go b/src/cmd/internal/moddeps/moddeps_test.go
35*4882a593Smuzhiyunindex 56c3b2585c..3306e29431 100644
36*4882a593Smuzhiyun--- a/src/cmd/internal/moddeps/moddeps_test.go
37*4882a593Smuzhiyun+++ b/src/cmd/internal/moddeps/moddeps_test.go
38*4882a593Smuzhiyun@@ -34,6 +34,8 @@ import (
39*4882a593Smuzhiyun // See issues 36852, 41409, and 43687.
40*4882a593Smuzhiyun // (Also see golang.org/issue/27348.)
41*4882a593Smuzhiyun func TestAllDependencies(t *testing.T) {
42*4882a593Smuzhiyun+	t.Skip("TODO(#53977): 1.18.5 contains unreleased changes from vendored modules")
43*4882a593Smuzhiyun+
44*4882a593Smuzhiyun 	goBin := testenv.GoToolPath(t)
45*4882a593Smuzhiyun
46*4882a593Smuzhiyun 	// Ensure that all packages imported within GOROOT
47*4882a593Smuzhiyundiff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go
48*4882a593Smuzhiyunindex bb82f24585..1e78f6cdb9 100644
49*4882a593Smuzhiyun--- a/src/net/http/h2_bundle.go
50*4882a593Smuzhiyun+++ b/src/net/http/h2_bundle.go
51*4882a593Smuzhiyun@@ -3384,10 +3384,11 @@ func (s http2SettingID) String() string {
52*4882a593Smuzhiyun // name (key). See httpguts.ValidHeaderName for the base rules.
53*4882a593Smuzhiyun //
54*4882a593Smuzhiyun // Further, http2 says:
55*4882a593Smuzhiyun-//   "Just as in HTTP/1.x, header field names are strings of ASCII
56*4882a593Smuzhiyun-//   characters that are compared in a case-insensitive
57*4882a593Smuzhiyun-//   fashion. However, header field names MUST be converted to
58*4882a593Smuzhiyun-//   lowercase prior to their encoding in HTTP/2. "
59*4882a593Smuzhiyun+//
60*4882a593Smuzhiyun+//	"Just as in HTTP/1.x, header field names are strings of ASCII
61*4882a593Smuzhiyun+//	characters that are compared in a case-insensitive
62*4882a593Smuzhiyun+//	fashion. However, header field names MUST be converted to
63*4882a593Smuzhiyun+//	lowercase prior to their encoding in HTTP/2. "
64*4882a593Smuzhiyun func http2validWireHeaderFieldName(v string) bool {
65*4882a593Smuzhiyun 	if len(v) == 0 {
66*4882a593Smuzhiyun 		return false
67*4882a593Smuzhiyun@@ -3578,8 +3579,8 @@ func (s *http2sorter) SortStrings(ss []string) {
68*4882a593Smuzhiyun // validPseudoPath reports whether v is a valid :path pseudo-header
69*4882a593Smuzhiyun // value. It must be either:
70*4882a593Smuzhiyun //
71*4882a593Smuzhiyun-//     *) a non-empty string starting with '/'
72*4882a593Smuzhiyun-//     *) the string '*', for OPTIONS requests.
73*4882a593Smuzhiyun+//	*) a non-empty string starting with '/'
74*4882a593Smuzhiyun+//	*) the string '*', for OPTIONS requests.
75*4882a593Smuzhiyun //
76*4882a593Smuzhiyun // For now this is only used a quick check for deciding when to clean
77*4882a593Smuzhiyun // up Opaque URLs before sending requests from the Transport.
78*4882a593Smuzhiyun@@ -5053,6 +5054,9 @@ func (sc *http2serverConn) startGracefulShutdownInternal() {
79*4882a593Smuzhiyun func (sc *http2serverConn) goAway(code http2ErrCode) {
80*4882a593Smuzhiyun 	sc.serveG.check()
81*4882a593Smuzhiyun 	if sc.inGoAway {
82*4882a593Smuzhiyun+		if sc.goAwayCode == http2ErrCodeNo {
83*4882a593Smuzhiyun+			sc.goAwayCode = code
84*4882a593Smuzhiyun+		}
85*4882a593Smuzhiyun 		return
86*4882a593Smuzhiyun 	}
87*4882a593Smuzhiyun 	sc.inGoAway = true
88*4882a593Smuzhiyun@@ -6265,8 +6269,9 @@ func (rws *http2responseWriterState) writeChunk(p []byte) (n int, err error) {
89*4882a593Smuzhiyun // prior to the headers being written. If the set of trailers is fixed
90*4882a593Smuzhiyun // or known before the header is written, the normal Go trailers mechanism
91*4882a593Smuzhiyun // is preferred:
92*4882a593Smuzhiyun-//    https://golang.org/pkg/net/http/#ResponseWriter
93*4882a593Smuzhiyun-//    https://golang.org/pkg/net/http/#example_ResponseWriter_trailers
94*4882a593Smuzhiyun+//
95*4882a593Smuzhiyun+//	https://golang.org/pkg/net/http/#ResponseWriter
96*4882a593Smuzhiyun+//	https://golang.org/pkg/net/http/#example_ResponseWriter_trailers
97*4882a593Smuzhiyun const http2TrailerPrefix = "Trailer:"
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun // promoteUndeclaredTrailers permits http.Handlers to set trailers
100*4882a593Smuzhiyun--
101*4882a593Smuzhiyun2.36.1
102*4882a593Smuzhiyun
103