diff --git a/0001-drop-hard-code-cert.patch b/0001-drop-hard-code-cert.patch
deleted file mode 100644
index 1af1acc73a346d0e546ae1f4be3c0f0bd6c55841..0000000000000000000000000000000000000000
--- a/0001-drop-hard-code-cert.patch
+++ /dev/null
@@ -1,135 +0,0 @@
-From 2720067ebfb7568792bb0c8fe3fbf095c89b77a9 Mon Sep 17 00:00:00 2001
-From: jingrui
-Date: Tue, 17 Mar 2020 17:43:33 +0800
-Subject: [PATCH] drop hard-code cert
-
-Signed-off-by: jingrui
----
- src/crypto/x509/test-file.crt | 32 ---------------------------
- src/crypto/x509/testdata/test-dir.crt | 31 --------------------------
- src/net/http/internal/testcert.go | 31 ++------------------------
- 3 files changed, 2 insertions(+), 92 deletions(-)
- delete mode 100644 src/crypto/x509/test-file.crt
- delete mode 100644 src/crypto/x509/testdata/test-dir.crt
-
-diff --git a/src/crypto/x509/test-file.crt b/src/crypto/x509/test-file.crt
-deleted file mode 100644
-index caa83b9..0000000
---- a/src/crypto/x509/test-file.crt
-+++ /dev/null
-@@ -1,32 +0,0 @@
-------BEGIN CERTIFICATE-----
--MIIFbTCCA1WgAwIBAgIJAN338vEmMtLsMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNV
--BAYTAlVLMRMwEQYDVQQIDApUZXN0LVN0YXRlMRUwEwYDVQQKDAxHb2xhbmcgVGVz
--dHMxEjAQBgNVBAMMCXRlc3QtZmlsZTAeFw0xNzAyMDEyMzUyMDhaFw0yNzAxMzAy
--MzUyMDhaME0xCzAJBgNVBAYTAlVLMRMwEQYDVQQIDApUZXN0LVN0YXRlMRUwEwYD
--VQQKDAxHb2xhbmcgVGVzdHMxEjAQBgNVBAMMCXRlc3QtZmlsZTCCAiIwDQYJKoZI
--hvcNAQEBBQADggIPADCCAgoCggIBAPMGiLjdiffQo3Xc8oUe7wsDhSaAJFOhO6Qs
--i0xYrYl7jmCuz9rGD2fdgk5cLqGazKuQ6fIFzHXFU2BKs4CWXt9KO0KFEhfvZeuW
--jG5d7C1ZUiuKOrPqjKVu8SZtFPc7y7Ke7msXzY+Z2LLyiJJ93LCMq4+cTSGNXVlI
--KqUxhxeoD5/QkUPyQy/ilu3GMYfx/YORhDP6Edcuskfj8wRh1UxBejP8YPMvI6St
--cE2GkxoEGqDWnQ/61F18te6WI3MD29tnKXOkXVhnSC+yvRLljotW2/tAhHKBG4tj
--iQWT5Ri4Wrw2tXxPKRLsVWc7e1/hdxhnuvYpXkWNhKsm002jzkFXlzfEwPd8nZdw
--5aT6gPUBN2AAzdoqZI7E200i0orEF7WaSoMfjU1tbHvExp3vyAPOfJ5PS2MQ6W03
--Zsy5dTVH+OBH++rkRzQCFcnIv/OIhya5XZ9KX9nFPgBEP7Xq2A+IjH7B6VN/S/bv
--8lhp2V+SQvlew9GttKC4hKuPsl5o7+CMbcqcNUdxm9gGkN8epGEKCuix97bpNlxN
--fHZxHE5+8GMzPXMkCD56y5TNKR6ut7JGHMPtGl5lPCLqzG/HzYyFgxsDfDUu2B0A
--GKj0lGpnLfGqwhs2/s3jpY7+pcvVQxEpvVTId5byDxu1ujP4HjO/VTQ2P72rE8Ft
--C6J2Av0tAgMBAAGjUDBOMB0GA1UdDgQWBBTLT/RbyfBB/Pa07oBnaM+QSJPO9TAf
--BgNVHSMEGDAWgBTLT/RbyfBB/Pa07oBnaM+QSJPO9TAMBgNVHRMEBTADAQH/MA0G
--CSqGSIb3DQEBCwUAA4ICAQB3sCntCcQwhMgRPPyvOCMyTcQ/Iv+cpfxz2Ck14nlx
--AkEAH2CH0ov5GWTt07/ur3aa5x+SAKi0J3wTD1cdiw4U/6Uin6jWGKKxvoo4IaeK
--SbM8w/6eKx6UbmHx7PA/eRABY9tTlpdPCVgw7/o3WDr03QM+IAtatzvaCPPczake
--pbdLwmBZB/v8V+6jUajy6jOgdSH0PyffGnt7MWgDETmNC6p/Xigp5eh+C8Fb4NGT
--xgHES5PBC+sruWp4u22bJGDKTvYNdZHsnw/CaKQWNsQqwisxa3/8N5v+PCff/pxl
--r05pE3PdHn9JrCl4iWdVlgtiI9BoPtQyDfa/OEFaScE8KYR8LxaAgdgp3zYncWls
--BpwQ6Y/A2wIkhlD9eEp5Ib2hz7isXOs9UwjdriKqrBXqcIAE5M+YIk3+KAQKxAtd
--4YsK3CSJ010uphr12YKqlScj4vuKFjuOtd5RyyMIxUG3lrrhAu2AzCeKCLdVgA8+
--75FrYMApUdvcjp4uzbBoED4XRQlx9kdFHVbYgmE/+yddBYJM8u4YlgAL0hW2/D8p
--z9JWIfxVmjJnBnXaKGBuiUyZ864A3PJndP6EMMo7TzS2CDnfCYuJjvI0KvDjFNmc
--rQA04+qfMSEz3nmKhbbZu4eYLzlADhfH8tT4GMtXf71WLA5AUHGf2Y4+HIHTsmHG
--vQ==
-------END CERTIFICATE-----
-diff --git a/src/crypto/x509/testdata/test-dir.crt b/src/crypto/x509/testdata/test-dir.crt
-deleted file mode 100644
-index b7fc9c5..0000000
---- a/src/crypto/x509/testdata/test-dir.crt
-+++ /dev/null
-@@ -1,31 +0,0 @@
-------BEGIN CERTIFICATE-----
--MIIFazCCA1OgAwIBAgIJAL8a/lsnspOqMA0GCSqGSIb3DQEBCwUAMEwxCzAJBgNV
--BAYTAlVLMRMwEQYDVQQIDApUZXN0LVN0YXRlMRUwEwYDVQQKDAxHb2xhbmcgVGVz
--dHMxETAPBgNVBAMMCHRlc3QtZGlyMB4XDTE3MDIwMTIzNTAyN1oXDTI3MDEzMDIz
--NTAyN1owTDELMAkGA1UEBhMCVUsxEzARBgNVBAgMClRlc3QtU3RhdGUxFTATBgNV
--BAoMDEdvbGFuZyBUZXN0czERMA8GA1UEAwwIdGVzdC1kaXIwggIiMA0GCSqGSIb3
--DQEBAQUAA4ICDwAwggIKAoICAQDzBoi43Yn30KN13PKFHu8LA4UmgCRToTukLItM
--WK2Je45grs/axg9n3YJOXC6hmsyrkOnyBcx1xVNgSrOAll7fSjtChRIX72Xrloxu
--XewtWVIrijqz6oylbvEmbRT3O8uynu5rF82Pmdiy8oiSfdywjKuPnE0hjV1ZSCql
--MYcXqA+f0JFD8kMv4pbtxjGH8f2DkYQz+hHXLrJH4/MEYdVMQXoz/GDzLyOkrXBN
--hpMaBBqg1p0P+tRdfLXuliNzA9vbZylzpF1YZ0gvsr0S5Y6LVtv7QIRygRuLY4kF
--k+UYuFq8NrV8TykS7FVnO3tf4XcYZ7r2KV5FjYSrJtNNo85BV5c3xMD3fJ2XcOWk
--+oD1ATdgAM3aKmSOxNtNItKKxBe1mkqDH41NbWx7xMad78gDznyeT0tjEOltN2bM
--uXU1R/jgR/vq5Ec0AhXJyL/ziIcmuV2fSl/ZxT4ARD+16tgPiIx+welTf0v27/JY
--adlfkkL5XsPRrbSguISrj7JeaO/gjG3KnDVHcZvYBpDfHqRhCgrosfe26TZcTXx2
--cRxOfvBjMz1zJAg+esuUzSkerreyRhzD7RpeZTwi6sxvx82MhYMbA3w1LtgdABio
--9JRqZy3xqsIbNv7N46WO/qXL1UMRKb1UyHeW8g8btboz+B4zv1U0Nj+9qxPBbQui
--dgL9LQIDAQABo1AwTjAdBgNVHQ4EFgQUy0/0W8nwQfz2tO6AZ2jPkEiTzvUwHwYD
--VR0jBBgwFoAUy0/0W8nwQfz2tO6AZ2jPkEiTzvUwDAYDVR0TBAUwAwEB/zANBgkq
--hkiG9w0BAQsFAAOCAgEAvEVnUYsIOt87rggmLPqEueynkuQ+562M8EDHSQl82zbe
--xDCxeg3DvPgKb+RvaUdt1362z/szK10SoeMgx6+EQLoV9LiVqXwNqeYfixrhrdw3
--ppAhYYhymdkbUQCEMHypmXP1vPhAz4o8Bs+eES1M+zO6ErBiD7SqkmBElT+GixJC
--6epC9ZQFs+dw3lPlbiZSsGE85sqc3VAs0/JgpL/pb1/Eg4s0FUhZD2C2uWdSyZGc
--g0/v3aXJCp4j/9VoNhI1WXz3M45nysZIL5OQgXymLqJElQa1pZ3Wa4i/nidvT4AT
--Xlxc/qijM8set/nOqp7hVd5J0uG6qdwLRILUddZ6OpXd7ZNi1EXg+Bpc7ehzGsDt
--3UFGzYXDjxYnK2frQfjLS8stOQIqSrGthW6x0fdkVx0y8BByvd5J6+JmZl4UZfzA
--m99VxXSt4B9x6BvnY7ktzcFDOjtuLc4B/7yg9fv1eQuStA4cHGGAttsCg1X/Kx8W
--PvkkeH0UWDZ9vhH9K36703z89da6MWF+bz92B0+4HoOmlVaXRkvblsNaynJnL0LC
--Ayry7QBxuh5cMnDdRwJB3AVJIiJ1GVpb7aGvBOnx+s2lwRv9HWtghb+cbwwktx1M
--JHyBf3GZNSWTpKY7cD8V+NnBv3UuioOVVo+XAU4LF/bYUjdRpxWADJizNtZrtFo=
-------END CERTIFICATE-----
-diff --git a/src/net/http/internal/testcert.go b/src/net/http/internal/testcert.go
-index 2284a83..a33d06b 100644
---- a/src/net/http/internal/testcert.go
-+++ b/src/net/http/internal/testcert.go
-@@ -10,36 +10,9 @@ import "strings"
- // "127.0.0.1" and "[::1]", expiring at Jan 29 16:00:00 2084 GMT.
- // generated from src/crypto/tls:
- // go run generate_cert.go --rsa-bits 1024 --host 127.0.0.1,::1,example.com --ca --start-date "Jan 1 00:00:00 1970" --duration=1000000h
--var LocalhostCert = []byte(`-----BEGIN CERTIFICATE-----
--MIICEzCCAXygAwIBAgIQMIMChMLGrR+QvmQvpwAU6zANBgkqhkiG9w0BAQsFADAS
--MRAwDgYDVQQKEwdBY21lIENvMCAXDTcwMDEwMTAwMDAwMFoYDzIwODQwMTI5MTYw
--MDAwWjASMRAwDgYDVQQKEwdBY21lIENvMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB
--iQKBgQDuLnQAI3mDgey3VBzWnB2L39JUU4txjeVE6myuDqkM/uGlfjb9SjY1bIw4
--iA5sBBZzHi3z0h1YV8QPuxEbi4nW91IJm2gsvvZhIrCHS3l6afab4pZBl2+XsDul
--rKBxKKtD1rGxlG4LjncdabFn9gvLZad2bSysqz/qTAUStTvqJQIDAQABo2gwZjAO
--BgNVHQ8BAf8EBAMCAqQwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0TAQH/BAUw
--AwEB/zAuBgNVHREEJzAlggtleGFtcGxlLmNvbYcEfwAAAYcQAAAAAAAAAAAAAAAA
--AAAAATANBgkqhkiG9w0BAQsFAAOBgQCEcetwO59EWk7WiJsG4x8SY+UIAA+flUI9
--tyC4lNhbcF2Idq9greZwbYCqTTTr2XiRNSMLCOjKyI7ukPoPjo16ocHj+P3vZGfs
--h1fIw3cSS2OolhloGw/XM6RWPWtPAlGykKLciQrBru5NAPvCMsb/I1DAceTiotQM
--fblo6RBxUQ==
-------END CERTIFICATE-----`)
-+var LocalhostCert = []byte(``)
-
- // LocalhostKey is the private key for localhostCert.
--var LocalhostKey = []byte(testingKey(`-----BEGIN RSA TESTING KEY-----
--MIICXgIBAAKBgQDuLnQAI3mDgey3VBzWnB2L39JUU4txjeVE6myuDqkM/uGlfjb9
--SjY1bIw4iA5sBBZzHi3z0h1YV8QPuxEbi4nW91IJm2gsvvZhIrCHS3l6afab4pZB
--l2+XsDulrKBxKKtD1rGxlG4LjncdabFn9gvLZad2bSysqz/qTAUStTvqJQIDAQAB
--AoGAGRzwwir7XvBOAy5tM/uV6e+Zf6anZzus1s1Y1ClbjbE6HXbnWWF/wbZGOpet
--3Zm4vD6MXc7jpTLryzTQIvVdfQbRc6+MUVeLKwZatTXtdZrhu+Jk7hx0nTPy8Jcb
--uJqFk541aEw+mMogY/xEcfbWd6IOkp+4xqjlFLBEDytgbIECQQDvH/E6nk+hgN4H
--qzzVtxxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLmQcj2PprIMmPcQrooz8vp
--jy4SHEg1AkEA/v13/5M47K9vCxmb8QeD/asydfsgS5TeuNi8DoUBEmiSJwma7FXY
--fFUtxuvL7XvjwjN5B30pNEbc6Iuyt7y4MQJBAIt21su4b3sjXNueLKH85Q+phy2U
--fQtuUE9txblTu14q3N7gHRZB4ZMhFYyDy8CKrN2cPg/Fvyt0Xlp/DoCzjA0CQQDU
--y2ptGsuSmgUtWj3NM9xuwYPm+Z/F84K6+ARYiZ6PYj013sovGKUFfYAqVXVlxtIX
--qyUBnu3X9ps8ZfjLZO7BAkEAlT4R5Yl6cGhaJQYZHOde3JEMhNRcVFMO8dJDaFeo
--f9Oeos0UUothgiDktdQHxdNEwLjQf7lJJBzV+5OtwswCWA==
-------END RSA TESTING KEY-----`))
-+var LocalhostKey = []byte(testingKey(``))
-
- func testingKey(s string) string { return strings.ReplaceAll(s, "TESTING KEY", "PRIVATE KEY") }
---
-2.17.1
-
diff --git a/0001-release-branch.go1.15-doc-go1.15-mention-1.15.3-cgo-.patch b/0001-release-branch.go1.15-doc-go1.15-mention-1.15.3-cgo-.patch
deleted file mode 100644
index dfe3597f83f78b4854a3674ee54364d0033ed1c2..0000000000000000000000000000000000000000
--- a/0001-release-branch.go1.15-doc-go1.15-mention-1.15.3-cgo-.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-From 069f9d96d179becc61231d566c9a75f1ec26e991 Mon Sep 17 00:00:00 2001
-From: Ian Lance Taylor
-Date: Fri, 11 Dec 2020 19:10:00 -0800
-Subject: [PATCH 01/44] [release-branch.go1.15] doc/go1.15: mention 1.15.3 cgo
- restriction on empty structs
-
-For #40954
-
-Change-Id: I6a30aed31a16e820817f4ca5c7f591222e922946
-Reviewed-on: https://go-review.googlesource.com/c/go/+/277432
-Trust: Ian Lance Taylor
-Reviewed-by: Keith Randall
-(cherry picked from commit 129bb1917b4914f0743ec9b4ef0dfb74df39c07d)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/278573
-Run-TryBot: Ian Lance Taylor
-TryBot-Result: Go Bot
-Reviewed-by: Dmitri Shuralyov
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/069f9d96d179becc61231d566c9a75f1ec26e991
-
----
- doc/go1.15.html | 13 +++++++++++++
- 1 file changed, 13 insertions(+)
-
-diff --git a/doc/go1.15.html b/doc/go1.15.html
-index c691bf3bd5..c9997c0ca3 100644
---- a/doc/go1.15.html
-+++ b/doc/go1.15.html
-@@ -397,6 +397,19 @@ Do not send CLs removing the interior tags from such phrases.
- documentation for more information.
-
-
-+
-+ In Go 1.15.3 and later, cgo will not permit Go code to allocate an
-+ undefined struct type (a C struct defined as just struct
-+ S;
or similar) on the stack or heap.
-+ Go code will only be permitted to use pointers to those types.
-+ Allocating an instance of such a struct and passing a pointer, or a
-+ full struct value, to C code was always unsafe and unlikely to work
-+ correctly; it is now forbidden.
-+ The fix is to either rewrite the Go code to use only pointers, or to
-+ ensure that the Go code sees the full definition of the struct by
-+ including the appropriate C header file.
-+
-+
- X.509 CommonName deprecation
-
-
---
-2.27.0
-
diff --git a/0061-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch b/0001-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch
similarity index 60%
rename from 0061-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch
rename to 0001-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch
index d0da46e29856dad78dc0f30056104cd289a5c5c1..6f993e03193c56d30da7f26fdb8cbdc9c9e95ebd 100644
--- a/0061-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch
+++ b/0001-release-branch.go1.17-crypto-elliptic-tolerate-zero-.patch
@@ -1,7 +1,7 @@
-From 0a42f7750216ff7ca3aa1c0fb3fcf6a1f431cca0 Mon Sep 17 00:00:00 2001
+From ad33fdc8f4bce612842d922ca701c3062fe4d4c6 Mon Sep 17 00:00:00 2001
From: Filippo Valsorda
Date: Thu, 31 Mar 2022 12:31:58 -0400
-Subject: [Backport] [release-branch.go1.17] crypto/elliptic: tolerate
+Subject: [Backport 1/2] [release-branch.go1.17] crypto/elliptic: tolerate
zero-padded scalars in generic P-256
Updates #52075
@@ -13,19 +13,32 @@ Reviewed-on: https://go-review.googlesource.com/c/go/+/397136
Trust: Filippo Valsorda
Reviewed-by: Julie Qiu
-Conflict: NA
-Reference: https://go-review.googlesource.com/c/go/+/397136
+Conflict:NA
+Reference:https://go-review.googlesource.com/c/go/+/399816,https://go-review.googlesource.com/c/go/+/397136
---
- src/crypto/elliptic/elliptic_test.go | 14 ++++++++++++++
- src/crypto/elliptic/p256.go | 2 +-
+ src/crypto/elliptic/p256.go | 2 +-
+ src/crypto/elliptic/p256_test.go | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
-diff --git a/src/crypto/elliptic/elliptic_test.go b/src/crypto/elliptic/elliptic_test.go
-index bb16b0d163..498f617198 100644
---- a/src/crypto/elliptic/elliptic_test.go
-+++ b/src/crypto/elliptic/elliptic_test.go
-@@ -802,3 +802,17 @@ func testInvalidCoordinates(t *testing.T, curve Curve) {
- checkIsOnCurveFalse("P, y", p, yy)
+diff --git a/src/crypto/elliptic/p256.go b/src/crypto/elliptic/p256.go
+index b2b12c8f13..da5283735c 100644
+--- a/src/crypto/elliptic/p256.go
++++ b/src/crypto/elliptic/p256.go
+@@ -52,7 +52,7 @@ func p256GetScalar(out *[32]byte, in []byte) {
+ n := new(big.Int).SetBytes(in)
+ var scalarBytes []byte
+
+- if n.Cmp(p256Params.N) >= 0 {
++ if n.Cmp(p256Params.N) >= 0 || len(in) > len(out) {
+ n.Mod(n, p256Params.N)
+ scalarBytes = n.Bytes()
+ } else {
+diff --git a/src/crypto/elliptic/p256_test.go b/src/crypto/elliptic/p256_test.go
+index 1435f5e1a5..694186df81 100644
+--- a/src/crypto/elliptic/p256_test.go
++++ b/src/crypto/elliptic/p256_test.go
+@@ -153,3 +153,17 @@ func TestP256CombinedMult(t *testing.T) {
+ t.Errorf("1×G + (-1)×G = (%d, %d), should be ∞", x, y)
}
}
+
@@ -42,19 +55,6 @@ index bb16b0d163..498f617198 100644
+ t.Errorf("unexpected output (%v,%v)", x, y)
+ }
+}
-diff --git a/src/crypto/elliptic/p256.go b/src/crypto/elliptic/p256.go
-index c23e414156..787e3e7444 100644
---- a/src/crypto/elliptic/p256.go
-+++ b/src/crypto/elliptic/p256.go
-@@ -51,7 +51,7 @@ func p256GetScalar(out *[32]byte, in []byte) {
- n := new(big.Int).SetBytes(in)
- var scalarBytes []byte
-
-- if n.Cmp(p256Params.N) >= 0 {
-+ if n.Cmp(p256Params.N) >= 0 || len(in) > len(out) {
- n.Mod(n, p256Params.N)
- scalarBytes = n.Bytes()
- } else {
--
2.30.0
diff --git a/0002-fix-patch-cmd-go-internal-modfetch-do-not-sho.patch b/0002-fix-patch-cmd-go-internal-modfetch-do-not-sho.patch
deleted file mode 100644
index beb1de472e356debda18f1b42492530b1765dacc..0000000000000000000000000000000000000000
--- a/0002-fix-patch-cmd-go-internal-modfetch-do-not-sho.patch
+++ /dev/null
@@ -1,77 +0,0 @@
-From d57e23e7bd6a8f80ace3f1d668a387cf1bc989f7 Mon Sep 17 00:00:00 2001
-From: hanchao
-Date: Wed, 23 Mar 2022 20:51:31 +0800
-Subject: [PATCH 2/2] fix patch
- cmd-go-internal-modfetch-do-not-short-circuit-canoni.patch
-
-reason:the above patch is to fix CVE-2022-23773, but it does not work with golang1.15,
-so this patch is used to fix the above issue.
-
-Conflict:NA
-Reference:https://go-review.googlesource.com/c/go/+/378400/
-
-Signed-off-by: hanchao
----
- src/cmd/go/internal/modfetch/coderepo.go | 24 +++++-------------------
- 1 file changed, 5 insertions(+), 19 deletions(-)
-
-diff --git a/src/cmd/go/internal/modfetch/coderepo.go b/src/cmd/go/internal/modfetch/coderepo.go
-index c654b36..def62d7 100644
---- a/src/cmd/go/internal/modfetch/coderepo.go
-+++ b/src/cmd/go/internal/modfetch/coderepo.go
-@@ -456,11 +456,6 @@ func (r *codeRepo) convert(info *codehost.RevInfo, statVers string) (*RevInfo, e
- tagPrefix = r.codeDir + "/"
- }
-
-- isRetracted, err := r.retractedVersions()
-- if err != nil {
-- isRetracted = func(string) bool { return false }
-- }
--
- // tagToVersion returns the version obtained by trimming tagPrefix from tag.
- // If the tag is invalid, retracted, or a pseudo-version, tagToVersion returns
- // an empty version.
-@@ -523,7 +518,7 @@ func (r *codeRepo) convert(info *codehost.RevInfo, statVers string) (*RevInfo, e
- }
- // Save the highest non-retracted canonical tag for the revision.
- // If we don't find a better match, we'll use it as the canonical version.
-- if tagIsCanonical && semver.Compare(highestCanonical, v) < 0 && !isRetracted(v) {
-+ if tagIsCanonical && semver.Compare(highestCanonical, v) < 0 {
- if module.MatchPathMajor(v, r.pathMajor) || canUseIncompatible(v) {
- highestCanonical = v
- }
-@@ -536,27 +531,18 @@ func (r *codeRepo) convert(info *codehost.RevInfo, statVers string) (*RevInfo, e
- return checkCanonical(highestCanonical)
- }
-
-- // Find the highest tagged version in the revision's history, subject to
-- // major version and +incompatible constraints. Use that version as the
-- // pseudo-version base so that the pseudo-version sorts higher. Ignore
-- // retracted versions.
-- allowedMajor := func(major string) func(v string) bool {
-- return func(v string) bool {
-- return ((major == "" && canUseIncompatible(v)) || semver.Major(v) == major) && !isRetracted(v)
-- }
-- }
- if pseudoBase == "" {
- var tag string
- if r.pseudoMajor != "" || canUseIncompatible("") {
-- tag, _ = r.code.RecentTag(info.Name, tagPrefix, allowedMajor(r.pseudoMajor))
-+ tag, _ = r.code.RecentTag(info.Name, tagPrefix, r.pseudoMajor)
- } else {
- // Allow either v1 or v0, but not incompatible higher versions.
-- tag, _ = r.code.RecentTag(info.Name, tagPrefix, allowedMajor("v1"))
-+ tag, _ = r.code.RecentTag(info.Name, tagPrefix, "v1")
- if tag == "" {
-- tag, _ = r.code.RecentTag(info.Name, tagPrefix, allowedMajor("v0"))
-+ tag, _ = r.code.RecentTag(info.Name, tagPrefix, "v0")
- }
- }
-- pseudoBase, _ = tagToVersion(tag)
-+ pseudoBase, _ = tagToVersion(tag) // empty if the tag is invalid
- }
-
- return checkCanonical(PseudoVersion(r.pseudoMajor, pseudoBase, info.Time, info.Short))
---
-2.30.0
-
diff --git a/0002-release-branch.go1.15-cmd-go-fix-mod_get_fallback-te.patch b/0002-release-branch.go1.15-cmd-go-fix-mod_get_fallback-te.patch
deleted file mode 100644
index 6b855bac47d78308a130c7c236da89f566d2ac85..0000000000000000000000000000000000000000
--- a/0002-release-branch.go1.15-cmd-go-fix-mod_get_fallback-te.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From aaef93bba34740d793e987d95355feb312f01cfd Mon Sep 17 00:00:00 2001
-From: Jay Conrod
-Date: Wed, 20 Jan 2021 09:45:03 -0500
-Subject: [PATCH 02/44] [release-branch.go1.15] cmd/go: fix mod_get_fallback
- test
-
-Fixes #43797
-
-Change-Id: I3d791d0ac9ce0b523c78c649aaf5e339a7f63b76
-Reviewed-on: https://go-review.googlesource.com/c/go/+/284797
-Trust: Jay Conrod
-Run-TryBot: Jay Conrod
-Reviewed-by: Bryan C. Mills
-TryBot-Result: Go Bot
-(cherry picked from commit be28e5abc5ddca0d6b2d8c91b7bb9c05717154e7)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/284799
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/aaef93bba34740d793e987d95355feb312f01cfd
-
----
- src/cmd/go/testdata/script/mod_get_fallback.txt | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/cmd/go/testdata/script/mod_get_fallback.txt b/src/cmd/go/testdata/script/mod_get_fallback.txt
-index a9834a324e..9733fa366b 100644
---- a/src/cmd/go/testdata/script/mod_get_fallback.txt
-+++ b/src/cmd/go/testdata/script/mod_get_fallback.txt
-@@ -6,5 +6,5 @@ env GOPROXY=https://proxy.golang.org,direct
- env GOSUMDB=off
-
- go get -x -v -d golang.org/x/tools/cmd/goimports
--stderr '# get https://proxy.golang.org/golang.org/x/tools/@latest'
-+stderr '# get https://proxy.golang.org/golang.org/x/tools/@v/list'
- ! stderr '# get https://golang.org'
---
-2.27.0
-
diff --git a/0062-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch b/0002-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch
similarity index 98%
rename from 0062-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch
rename to 0002-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch
index 25fc23002c6e543bf9554a53bc191df0ef8c7039..243596c90ead364fc953a1fd4144479adb812e12 100644
--- a/0062-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch
+++ b/0002-release-branch.go1.17-encoding-pem-fix-stack-overflo.patch
@@ -1,4 +1,4 @@
-From bef7ed470e9a784e1b736c5847aabef2d9ac8094 Mon Sep 17 00:00:00 2001
+From baaaf3ce29bf98efc00c2f06c531f2b0186b027b Mon Sep 17 00:00:00 2001
From: Julie Qiu
Date: Tue, 1 Mar 2022 10:19:38 -0600
Subject: [Backport 2/2] [release-branch.go1.17] encoding/pem: fix stack
@@ -234,7 +234,7 @@ index a7272da5ad..1bee1c12d2 100644
const pemLineLength = 64
diff --git a/src/encoding/pem/pem_test.go b/src/encoding/pem/pem_test.go
-index 8515b46498..44855812b0 100644
+index b2b6b15e73..c94b5ca53b 100644
--- a/src/encoding/pem/pem_test.go
+++ b/src/encoding/pem/pem_test.go
@@ -107,6 +107,12 @@ const pemMissingEndingSpace = `
diff --git a/0003-release-branch.go1.15-internal-execabs-only-run-test.patch b/0003-release-branch.go1.15-internal-execabs-only-run-test.patch
deleted file mode 100644
index bfa22efdc077af7a510c18fe03661b64be14a9e4..0000000000000000000000000000000000000000
--- a/0003-release-branch.go1.15-internal-execabs-only-run-test.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-From e540758b604dd46b682593e284cf77a61ce3fde6 Mon Sep 17 00:00:00 2001
-From: Roland Shoemaker
-Date: Wed, 20 Jan 2021 09:06:12 -0800
-Subject: [PATCH 03/44] [release-branch.go1.15] internal/execabs: only run
- tests on platforms that support them
-
-Fixes #43793
-
-Change-Id: I3bf022a28b194f0089ea96d93e56bbd9fb7e0aa8
-Reviewed-on: https://go-review.googlesource.com/c/go/+/285056
-Trust: Roland Shoemaker
-Run-TryBot: Roland Shoemaker
-Reviewed-by: Dmitri Shuralyov
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/e540758b604dd46b682593e284cf77a61ce3fde6
-
----
- src/internal/execabs/execabs_test.go | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/src/internal/execabs/execabs_test.go b/src/internal/execabs/execabs_test.go
-index a0b88dd2a0..1a197b8701 100644
---- a/src/internal/execabs/execabs_test.go
-+++ b/src/internal/execabs/execabs_test.go
-@@ -7,6 +7,7 @@ package execabs
- import (
- "context"
- "fmt"
-+ "internal/testenv"
- "io/ioutil"
- "os"
- "os/exec"
-@@ -30,6 +31,8 @@ func TestFixCmd(t *testing.T) {
- }
-
- func TestCommand(t *testing.T) {
-+ testenv.MustHaveExec(t)
-+
- for _, cmd := range []func(string) *Cmd{
- func(s string) *Cmd { return Command(s) },
- func(s string) *Cmd { return CommandContext(context.Background(), s) },
-@@ -71,6 +74,8 @@ func TestCommand(t *testing.T) {
- }
-
- func TestLookPath(t *testing.T) {
-+ testenv.MustHaveExec(t)
-+
- tmpDir, err := ioutil.TempDir("", "execabs-test")
- if err != nil {
- t.Fatalf("ioutil.TempDir failed: %s", err)
---
-2.27.0
-
diff --git a/0063-release-branch.go1.16-syscall-fix-ForkLock-spurious-.patch b/0003-release-branch.go1.17-syscall-fix-ForkLock-spurious-.patch
similarity index 79%
rename from 0063-release-branch.go1.16-syscall-fix-ForkLock-spurious-.patch
rename to 0003-release-branch.go1.17-syscall-fix-ForkLock-spurious-.patch
index efa0922eda83232e26ef59c3be0733e8b03bec7d..64aee693f6998b6f9dd75f404673a048b9e74a24 100644
--- a/0063-release-branch.go1.16-syscall-fix-ForkLock-spurious-.patch
+++ b/0003-release-branch.go1.17-syscall-fix-ForkLock-spurious-.patch
@@ -1,7 +1,7 @@
-From 98e370069ffceeeeecb94c0b8e6c60c33994071a Mon Sep 17 00:00:00 2001
+From e7aab832069d06d77e04a585803dfdb04453253a Mon Sep 17 00:00:00 2001
From: Russ Cox
Date: Wed, 8 Dec 2021 18:05:11 -0500
-Subject: [PATCH] [release-branch.go1.16] syscall: fix ForkLock spurious
+Subject: [PATCH] [release-branch.go1.17] syscall: fix ForkLock spurious
close(0) on pipe failure
Pipe (and therefore forkLockPipe) does not make any guarantees
@@ -15,23 +15,20 @@ Fixes CVE-2021-44717
Change-Id: Iff8e19a6efbba0c73cc8b13ecfae381c87600bb4
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1291270
Reviewed-by: Ian Lance Taylor
-Reviewed-on: https://go-review.googlesource.com/c/go/+/370514
+Reviewed-on: https://go-review.googlesource.com/c/go/+/370534
Trust: Filippo Valsorda
Run-TryBot: Filippo Valsorda
TryBot-Result: Gopher Robot
Reviewed-by: Alex Rakoczy
-
-Conflict: NA
-Conference: https://go-review.googlesource.com/c/go/+/370514
---
src/syscall/exec_unix.go | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/src/syscall/exec_unix.go b/src/syscall/exec_unix.go
-index cb08b7084c..3a8ef0925e 100644
+index 54b18dccd7..c9c9d1abf3 100644
--- a/src/syscall/exec_unix.go
+++ b/src/syscall/exec_unix.go
-@@ -152,9 +152,6 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
+@@ -153,9 +153,6 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
sys = &zeroSysProcAttr
}
@@ -41,7 +38,7 @@ index cb08b7084c..3a8ef0925e 100644
// Convert args to C form.
argv0p, err := BytePtrFromString(argv0)
if err != nil {
-@@ -204,14 +201,17 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
+@@ -205,14 +202,17 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
// Allocate child status pipe close on exec.
if err = forkExecPipe(p[:]); err != nil {
@@ -62,7 +59,7 @@ index cb08b7084c..3a8ef0925e 100644
}
ForkLock.Unlock()
-@@ -243,14 +243,6 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
+@@ -244,14 +244,6 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
// Read got EOF, so pipe closed on exec, so exec succeeded.
return pid, nil
diff --git a/0004-backport-cmd-link-mark-unexported-methods-for-plugins.patch b/0004-backport-cmd-link-mark-unexported-methods-for-plugins.patch
new file mode 100644
index 0000000000000000000000000000000000000000..6b9dd4b07c525c5e2263c1abb1c7c8fa199f8c92
--- /dev/null
+++ b/0004-backport-cmd-link-mark-unexported-methods-for-plugins.patch
@@ -0,0 +1,39 @@
+From c872b0594f716a2a0799b07d7226a45f02c005f1 Mon Sep 17 00:00:00 2001
+From: Cherry Mui
+Date: Wed, 16 Mar 2022 13:07:57 -0400
+Subject: [PATCH] cmd/link: mark unexported methods for plugins
+
+When plugin is used, we already mark all exported methods
+reachable. However, when the plugin and the host program share
+a common package, an unexported method could also be reachable
+from both the plugin and the host via interfaces. We need to mark
+them as well.
+
+Fixes #51621.
+
+Change-Id: I1a70d3f96b66b803f2d0ab14d00ed0df276ea500
+Reviewed-on: https://go-review.googlesource.com/c/go/+/393365
+Trust: Cherry Mui
+Run-TryBot: Cherry Mui
+TryBot-Result: Gopher Robot
+Reviewed-by: Than McIntosh
+---
+ src/cmd/link/internal/ld/deadcode.go | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go
+index e4fa75f..21a9703 100644
+--- a/src/cmd/link/internal/ld/deadcode.go
++++ b/src/cmd/link/internal/ld/deadcode.go
+@@ -350,7 +350,7 @@ func deadcode(ctxt *Link) {
+ // in the last pass.
+ rem := d.markableMethods[:0]
+ for _, m := range d.markableMethods {
+- if (d.reflectSeen && m.isExported()) || d.ifaceMethod[m.m] {
++ if (d.reflectSeen && (m.isExported() || d.dynlink)) || d.ifaceMethod[m.m] {
+ d.markMethod(m)
+ } else {
+ rem = append(rem, m)
+--
+1.8.3.1
+
diff --git a/0004-release-branch.go1.15-cmd-compile-don-t-short-circui.patch b/0004-release-branch.go1.15-cmd-compile-don-t-short-circui.patch
deleted file mode 100644
index c2211d5fee1929812876453170798551a7a69bd4..0000000000000000000000000000000000000000
--- a/0004-release-branch.go1.15-cmd-compile-don-t-short-circui.patch
+++ /dev/null
@@ -1,154 +0,0 @@
-From 27d5fccd2119099c70ab6a4418626beac7a97b4b Mon Sep 17 00:00:00 2001
-From: Keith Randall
-Date: Thu, 7 Jan 2021 14:57:53 -0800
-Subject: [PATCH 04/44] [release-branch.go1.15] cmd/compile: don't
- short-circuit copies whose source is volatile
-
-Current optimization: When we copy a->b and then b->c, we might as well
-copy a->c instead of b->c (then b might be dead and go away).
-
-*Except* if a is a volatile location (might be clobbered by a call).
-In that case, we really do want to copy a immediately, because there
-might be a call before we can do the a->c copy.
-
-User calls can't happen in between, because the rule matches up the
-memory states. But calls inserted for memory barriers, particularly
-runtime.typedmemmove, can.
-
-(I guess we could introduce a register-calling-convention version
-of runtime.typedmemmove, but that seems a bigger change than this one.)
-
-Fixes #43575
-
-Change-Id: Ifa518bb1a6f3a8dd46c352d4fd54ea9713b3eb1a
-Reviewed-on: https://go-review.googlesource.com/c/go/+/282492
-Trust: Keith Randall
-Trust: Josh Bleecher Snyder
-Run-TryBot: Keith Randall
-TryBot-Result: Go Bot
-Reviewed-by: Josh Bleecher Snyder
-(cherry picked from commit 304f769ffc68e64244266b3aadbf91e6738c0064)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/282558
-Trust: Dmitri Shuralyov
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/27d5fccd2119099c70ab6a4418626beac7a97b4b
-
----
- .../compile/internal/ssa/gen/generic.rules | 4 +-
- .../compile/internal/ssa/rewritegeneric.go | 8 ++--
- test/fixedbugs/issue43570.go | 40 +++++++++++++++++++
- 3 files changed, 46 insertions(+), 6 deletions(-)
- create mode 100644 test/fixedbugs/issue43570.go
-
-diff --git a/src/cmd/compile/internal/ssa/gen/generic.rules b/src/cmd/compile/internal/ssa/gen/generic.rules
-index ed5bfc81fd..8bbe913380 100644
---- a/src/cmd/compile/internal/ssa/gen/generic.rules
-+++ b/src/cmd/compile/internal/ssa/gen/generic.rules
-@@ -2404,7 +2404,7 @@
- (Move {t1} [s] dst tmp1 midmem:(Move {t2} [s] tmp2 src _))
- && t1.Compare(t2) == types.CMPeq
- && isSamePtr(tmp1, tmp2)
-- && isStackPtr(src)
-+ && isStackPtr(src) && !isVolatile(src)
- && disjoint(src, s, tmp2, s)
- && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))
- => (Move {t1} [s] dst src midmem)
-@@ -2413,7 +2413,7 @@
- (Move {t1} [s] dst tmp1 midmem:(VarDef (Move {t2} [s] tmp2 src _)))
- && t1.Compare(t2) == types.CMPeq
- && isSamePtr(tmp1, tmp2)
-- && isStackPtr(src)
-+ && isStackPtr(src) && !isVolatile(src)
- && disjoint(src, s, tmp2, s)
- && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))
- => (Move {t1} [s] dst src midmem)
-diff --git a/src/cmd/compile/internal/ssa/rewritegeneric.go b/src/cmd/compile/internal/ssa/rewritegeneric.go
-index 9f4e1b95bd..6a09616aad 100644
---- a/src/cmd/compile/internal/ssa/rewritegeneric.go
-+++ b/src/cmd/compile/internal/ssa/rewritegeneric.go
-@@ -13666,7 +13666,7 @@ func rewriteValuegeneric_OpMove(v *Value) bool {
- return true
- }
- // match: (Move {t1} [s] dst tmp1 midmem:(Move {t2} [s] tmp2 src _))
-- // cond: t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))
-+ // cond: t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && !isVolatile(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))
- // result: (Move {t1} [s] dst src midmem)
- for {
- s := auxIntToInt64(v.AuxInt)
-@@ -13680,7 +13680,7 @@ func rewriteValuegeneric_OpMove(v *Value) bool {
- t2 := auxToType(midmem.Aux)
- src := midmem.Args[1]
- tmp2 := midmem.Args[0]
-- if !(t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))) {
-+ if !(t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && !isVolatile(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))) {
- break
- }
- v.reset(OpMove)
-@@ -13690,7 +13690,7 @@ func rewriteValuegeneric_OpMove(v *Value) bool {
- return true
- }
- // match: (Move {t1} [s] dst tmp1 midmem:(VarDef (Move {t2} [s] tmp2 src _)))
-- // cond: t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))
-+ // cond: t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && !isVolatile(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))
- // result: (Move {t1} [s] dst src midmem)
- for {
- s := auxIntToInt64(v.AuxInt)
-@@ -13708,7 +13708,7 @@ func rewriteValuegeneric_OpMove(v *Value) bool {
- t2 := auxToType(midmem_0.Aux)
- src := midmem_0.Args[1]
- tmp2 := midmem_0.Args[0]
-- if !(t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))) {
-+ if !(t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && !isVolatile(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))) {
- break
- }
- v.reset(OpMove)
-diff --git a/test/fixedbugs/issue43570.go b/test/fixedbugs/issue43570.go
-new file mode 100644
-index 0000000000..d073fde5f6
---- /dev/null
-+++ b/test/fixedbugs/issue43570.go
-@@ -0,0 +1,40 @@
-+// run
-+
-+// Copyright 2021 The Go Authors. All rights reserved.
-+// Use of this source code is governed by a BSD-style
-+// license that can be found in the LICENSE file.
-+
-+package main
-+
-+import "fmt"
-+
-+type T [8]*int
-+
-+//go:noinline
-+func f(x int) T {
-+ return T{}
-+}
-+
-+//go:noinline
-+func g(x int, t T) {
-+ if t != (T{}) {
-+ panic(fmt.Sprintf("bad: %v", t))
-+ }
-+}
-+
-+func main() {
-+ const N = 10000
-+ var q T
-+ func() {
-+ for i := 0; i < N; i++ {
-+ q = f(0)
-+ g(0, q)
-+ sink = make([]byte, 1024)
-+ }
-+ }()
-+ // Note that the closure is a trick to get the write to q to be a
-+ // write to a pointer that is known to be non-nil and requires
-+ // a write barrier.
-+}
-+
-+var sink []byte
---
-2.27.0
-
diff --git a/0005-release-branch.go1.15-cmd-go-fix-get_update_unknown_.patch b/0005-release-branch.go1.15-cmd-go-fix-get_update_unknown_.patch
deleted file mode 100644
index 7c01a1940ca6c925b6c52ad36cf96a473f93676d..0000000000000000000000000000000000000000
--- a/0005-release-branch.go1.15-cmd-go-fix-get_update_unknown_.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From 9bb97ea047890e900dae04202a231685492c4b18 Mon Sep 17 00:00:00 2001
-From: Jay Conrod
-Date: Fri, 22 Jan 2021 16:59:16 -0500
-Subject: [PATCH 05/44] [release-branch.go1.15] cmd/go: fix
- get_update_unknown_protocol test
-
-This test needs to run in GOPATH mode. It broke when a go.mod file was
-added to github.com/golang/example. This change sets GO111MODULE=off,
-which matches master since CL 255051.
-
-Fixes #43861
-
-Change-Id: I9ea109a99509fac3185756a0f0d852a84c677bf5
-Reviewed-on: https://go-review.googlesource.com/c/go/+/285956
-Trust: Jay Conrod
-Run-TryBot: Jay Conrod
-TryBot-Result: Go Bot
-Reviewed-by: Bryan C. Mills
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/9bb97ea047890e900dae04202a231685492c4b18
-
----
- src/cmd/go/testdata/script/get_update_unknown_protocol.txt | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/src/cmd/go/testdata/script/get_update_unknown_protocol.txt b/src/cmd/go/testdata/script/get_update_unknown_protocol.txt
-index 85c2e24bc8..b00adea70b 100644
---- a/src/cmd/go/testdata/script/get_update_unknown_protocol.txt
-+++ b/src/cmd/go/testdata/script/get_update_unknown_protocol.txt
-@@ -1,5 +1,6 @@
- [!net] skip
- [!exec:git] skip
-+env GO111MODULE=off
-
- # Clone the repo via HTTPS manually.
- exec git clone -q https://github.com/golang/example github.com/golang/example
-@@ -10,4 +11,4 @@ cd github.com/golang/example
- exec git remote set-url origin xyz://github.com/golang/example
- exec git config --local url.https://github.com/.insteadOf xyz://github.com/
-
--go get -d -u -f github.com/golang/example/hello
-\ No newline at end of file
-+go get -d -u -f github.com/golang/example/hello
---
-2.27.0
-
diff --git a/0064-release-branch.go1.17-net-http-preserve-nil-values-i.patch b/0005-release-branch.go1.17-net-http-preserve-nil-values-i.patch
similarity index 90%
rename from 0064-release-branch.go1.17-net-http-preserve-nil-values-i.patch
rename to 0005-release-branch.go1.17-net-http-preserve-nil-values-i.patch
index 3782251ce605851c47182dca720dc73a59206466..98972340a918d866c0322d17b1c10068f2f57910 100644
--- a/0064-release-branch.go1.17-net-http-preserve-nil-values-i.patch
+++ b/0005-release-branch.go1.17-net-http-preserve-nil-values-i.patch
@@ -1,7 +1,7 @@
-From a6115663a62fb5559d023e32058f2219dd466095 Mon Sep 17 00:00:00 2001
+From 67bff2eb995a098f838fa4b799c0b8261292e6e7 Mon Sep 17 00:00:00 2001
From: Damien Neil
Date: Fri, 17 Jun 2022 10:09:45 -0700
-Subject: [PATCH 01/10] [release-branch.go1.17] net/http: preserve nil values
+Subject: [PATCH 01/11] [release-branch.go1.17] net/http: preserve nil values
in Header.Clone
ReverseProxy makes a distinction between nil and zero-length header values.
@@ -33,10 +33,10 @@ Reference: https://go-review.googlesource.com/c/go/+/415221
2 files changed, 11 insertions(+)
diff --git a/src/net/http/header.go b/src/net/http/header.go
-index b9b53911f38..221f613f642 100644
+index 4c72dcb2c88..ef4ee7ffa81 100644
--- a/src/net/http/header.go
+++ b/src/net/http/header.go
-@@ -100,6 +100,12 @@ func (h Header) Clone() Header {
+@@ -101,6 +101,12 @@ func (h Header) Clone() Header {
sv := make([]string, nv) // shared backing array for headers' values
h2 := make(Header, len(h))
for k, vv := range h {
diff --git a/0006-release-branch.go1.15-net-http-update-bundled-x-net-.patch b/0006-release-branch.go1.15-net-http-update-bundled-x-net-.patch
deleted file mode 100644
index 35e6235d3086f30c94a948dca5d669f35e9d36f2..0000000000000000000000000000000000000000
--- a/0006-release-branch.go1.15-net-http-update-bundled-x-net-.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-From a01db0df00fed281f6a9673eb93fe6acae6197cf Mon Sep 17 00:00:00 2001
-From: Damien Neil
-Date: Fri, 29 Jan 2021 11:01:37 -0800
-Subject: [PATCH 06/44] [release-branch.go1.15] net/http: update bundled
- x/net/http2
-
-Updates bundled http2 to x/net git rev 16c2bbf55 for:
-
- http2: send a nil error if we cancel a delayed body write
- https://golang.org/cl/288013
-
- http2: wait until the request body has been written
- https://golang.org/cl/288012
-
-Created by:
-
-go mod edit -replace=golang.org/x/net=golang.org/x/net@release-branch.go1.15-bundle
-GOFLAGS='-mod=mod' go generate -run=bundle std
-go mod edit -dropreplace=golang.org/x/net
-go get -d golang.org/x/net@release-branch.go1.15
-go mod tidy
-go mod vendor
-
-Fixes golang/go#42539
-
-Change-Id: I299c6d4a67ebc036e45c978e4d03cba73717b363
-Reviewed-on: https://go-review.googlesource.com/c/go/+/288112
-Trust: Damien Neil
-Run-TryBot: Damien Neil
-Reviewed-by: Dmitri Shuralyov
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/a01db0df00fed281f6a9673eb93fe6acae6197cf
-
----
- src/net/http/h2_bundle.go | 12 ++++++++++--
- 1 file changed, 10 insertions(+), 2 deletions(-)
-
-diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go
-index b03b84d2f3..678c6eb9d4 100644
---- a/src/net/http/h2_bundle.go
-+++ b/src/net/http/h2_bundle.go
-@@ -7592,6 +7592,9 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe
- // we can keep it.
- bodyWriter.cancel()
- cs.abortRequestBodyWrite(http2errStopReqBodyWrite)
-+ if hasBody && !bodyWritten {
-+ <-bodyWriter.resc
-+ }
- }
- if re.err != nil {
- cc.forgetStreamID(cs.ID)
-@@ -7612,6 +7615,7 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe
- } else {
- bodyWriter.cancel()
- cs.abortRequestBodyWrite(http2errStopReqBodyWriteAndCancel)
-+ <-bodyWriter.resc
- }
- cc.forgetStreamID(cs.ID)
- return nil, cs.getStartedWrite(), http2errTimeout
-@@ -7621,6 +7625,7 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe
- } else {
- bodyWriter.cancel()
- cs.abortRequestBodyWrite(http2errStopReqBodyWriteAndCancel)
-+ <-bodyWriter.resc
- }
- cc.forgetStreamID(cs.ID)
- return nil, cs.getStartedWrite(), ctx.Err()
-@@ -7630,6 +7635,7 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe
- } else {
- bodyWriter.cancel()
- cs.abortRequestBodyWrite(http2errStopReqBodyWriteAndCancel)
-+ <-bodyWriter.resc
- }
- cc.forgetStreamID(cs.ID)
- return nil, cs.getStartedWrite(), http2errRequestCanceled
-@@ -7639,6 +7645,7 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe
- // forgetStreamID.
- return nil, cs.getStartedWrite(), cs.resetErr
- case err := <-bodyWriter.resc:
-+ bodyWritten = true
- // Prefer the read loop's response, if available. Issue 16102.
- select {
- case re := <-readLoopResCh:
-@@ -7649,7 +7656,6 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe
- cc.forgetStreamID(cs.ID)
- return nil, cs.getStartedWrite(), err
- }
-- bodyWritten = true
- if d := cc.responseHeaderTimeout(); d != 0 {
- timer := time.NewTimer(d)
- defer timer.Stop()
-@@ -9060,7 +9066,9 @@ func (t *http2Transport) getBodyWriterState(cs *http2clientStream, body io.Reade
-
- func (s http2bodyWriterState) cancel() {
- if s.timer != nil {
-- s.timer.Stop()
-+ if s.timer.Stop() {
-+ s.resc <- nil
-+ }
- }
- }
-
---
-2.27.0
-
diff --git a/0065-release-branch.go1.17-go-parser-limit-recursion-dept.patch b/0006-release-branch.go1.17-go-parser-limit-recursion-dept.patch
similarity index 78%
rename from 0065-release-branch.go1.17-go-parser-limit-recursion-dept.patch
rename to 0006-release-branch.go1.17-go-parser-limit-recursion-dept.patch
index 18ff8b9b5a23b8b295eb99419c309ce99646f049..23a903a9e5c421b420127404315fbf9983f6fde8 100644
--- a/0065-release-branch.go1.17-go-parser-limit-recursion-dept.patch
+++ b/0006-release-branch.go1.17-go-parser-limit-recursion-dept.patch
@@ -1,7 +1,8 @@
-From ef7049cb34d5e2d3b4afbd37d3964cd8baf07282 Mon Sep 17 00:00:00 2001
+From b78e521644334294019da243a5ff57436f70cd72 Mon Sep 17 00:00:00 2001
From: Roland Shoemaker
Date: Wed, 15 Jun 2022 10:43:05 -0700
-Subject: [PATCH] go/parser: limit recursion depth
+Subject: [PATCH 02/11] [release-branch.go1.17] go/parser: limit recursion
+ depth
Limit nested parsing to 100,000, which prevents stack exhaustion when
parsing deeply nested statements, types, and expressions. Also limit
@@ -23,41 +24,20 @@ Reviewed-by: Heschi Kreinick
TryBot-Result: Gopher Robot
Run-TryBot: Michael Knyszek
-Conflict: src/go/parser/parser.go
+Conflict: NA
Reference: https://go-review.googlesource.com/c/go/+/417070
---
- src/go/parser/interface.go | 25 +++--
- src/go/parser/parser.go | 64 ++++++++++---
- src/go/parser/parser_test.go | 171 +++++++++++++++++++++++++++++++++++
- 3 files changed, 240 insertions(+), 20 deletions(-)
+ src/go/parser/interface.go | 10 ++-
+ src/go/parser/parser.go | 54 ++++++++++-
+ src/go/parser/parser_test.go | 169 +++++++++++++++++++++++++++++++++++
+ src/go/parser/resolver.go | 9 ++
+ 4 files changed, 236 insertions(+), 6 deletions(-)
diff --git a/src/go/parser/interface.go b/src/go/parser/interface.go
-index 54f9d7b..9fc9f7a 100644
+index 85486d2f4b4..eae429e6ef3 100644
--- a/src/go/parser/interface.go
+++ b/src/go/parser/interface.go
-@@ -49,13 +49,14 @@ func readSource(filename string, src interface{}) ([]byte, error) {
- type Mode uint
-
- const (
-- PackageClauseOnly Mode = 1 << iota // stop parsing after package clause
-- ImportsOnly // stop parsing after import declarations
-- ParseComments // parse comments and add them to AST
-- Trace // print a trace of parsed productions
-- DeclarationErrors // report declaration errors
-- SpuriousErrors // same as AllErrors, for backward-compatibility
-- AllErrors = SpuriousErrors // report all errors (not just the first 10 on different lines)
-+ PackageClauseOnly Mode = 1 << iota // stop parsing after package clause
-+ ImportsOnly // stop parsing after import declarations
-+ ParseComments // parse comments and add them to AST
-+ Trace // print a trace of parsed productions
-+ DeclarationErrors // report declaration errors
-+ SpuriousErrors // same as AllErrors, for backward-compatibility
-+ SkipObjectResolution // don't resolve identifiers to objects - see ParseFile
-+ AllErrors = SpuriousErrors // report all errors (not just the first 10 on different lines)
- )
-
- // ParseFile parses the source code of a single Go source file and returns
-@@ -92,8 +93,11 @@ func ParseFile(fset *token.FileSet, filename string, src interface{}, mode Mode)
+@@ -97,8 +97,11 @@ func ParseFile(fset *token.FileSet, filename string, src interface{}, mode Mode)
defer func() {
if e := recover(); e != nil {
// resume same panic if it's not a bailout
@@ -70,7 +50,7 @@ index 54f9d7b..9fc9f7a 100644
}
}
-@@ -188,8 +192,11 @@ func ParseExprFrom(fset *token.FileSet, filename string, src interface{}, mode M
+@@ -203,8 +206,11 @@ func ParseExprFrom(fset *token.FileSet, filename string, src interface{}, mode M
defer func() {
if e := recover(); e != nil {
// resume same panic if it's not a bailout
@@ -84,13 +64,13 @@ index 54f9d7b..9fc9f7a 100644
}
p.errors.Sort()
diff --git a/src/go/parser/parser.go b/src/go/parser/parser.go
-index 31a7398..29bf774 100644
+index f10c8650afd..2c42b9f8cc2 100644
--- a/src/go/parser/parser.go
+++ b/src/go/parser/parser.go
-@@ -68,6 +68,10 @@ type parser struct {
- // (maintained by open/close LabelScope)
- labelScope *ast.Scope // label scope for current function
- targetStack [][]*ast.Ident // stack of unresolved labels
+@@ -60,6 +60,10 @@ type parser struct {
+ inRhs bool // if set, the parser is parsing a rhs expression
+
+ imports []*ast.ImportSpec // list of imports
+
+ // nestLev is used to track and limit the recursion depth
+ // during parsing.
@@ -98,7 +78,7 @@ index 31a7398..29bf774 100644
}
func (p *parser) init(fset *token.FileSet, filename string, src []byte, mode Mode) {
-@@ -236,6 +240,24 @@ func un(p *parser) {
+@@ -110,6 +114,24 @@ func un(p *parser) {
p.printTrace(")")
}
@@ -123,7 +103,7 @@ index 31a7398..29bf774 100644
// Advance to the next token.
func (p *parser) next0() {
// Because of one-token look-ahead, print the previous token
-@@ -348,8 +370,12 @@ func (p *parser) next() {
+@@ -222,8 +244,12 @@ func (p *parser) next() {
}
}
@@ -137,30 +117,21 @@ index 31a7398..29bf774 100644
+}
func (p *parser) error(pos token.Pos, msg string) {
- epos := p.file.Position(pos)
-@@ -1030,6 +1056,8 @@ func (p *parser) parseChanType() *ast.ChanType {
+ if p.trace {
+@@ -1119,6 +1145,8 @@ func (p *parser) parseTypeInstance(typ ast.Expr) ast.Expr {
+ }
- // If the result is an identifier, it is not resolved.
func (p *parser) tryIdentOrType() ast.Expr {
+ defer decNestLev(incNestLev(p))
+
switch p.tok {
case token.IDENT:
- return p.parseTypeName()
-@@ -1470,14 +1498,19 @@ func (p *parser) checkExprOrType(x ast.Expr) ast.Expr {
- }
-
- // If lhs is set and the result is an identifier, it is not resolved.
--func (p *parser) parsePrimaryExpr(lhs bool) ast.Expr {
-+func (p *parser) parsePrimaryExpr(lhs bool) (x ast.Expr) {
- if p.trace {
- defer un(trace(p, "PrimaryExpr"))
+ typ := p.parseTypeName(nil)
+@@ -1531,7 +1559,13 @@ func (p *parser) parsePrimaryExpr() (x ast.Expr) {
}
-- x := p.parseOperand(lhs)
--L:
+ x = p.parseOperand()
- for {
-+ x = p.parseOperand(lhs)
+ // We track the nesting here rather than at the entry for the function,
+ // since it can iteratively produce a nested output, and we want to
+ // limit how deep a structure we generate.
@@ -171,33 +142,19 @@ index 31a7398..29bf774 100644
switch p.tok {
case token.PERIOD:
p.next()
-@@ -1513,19 +1546,18 @@ L:
- }
- x = p.parseLiteralValue(x)
- } else {
-- break L
-+ return
- }
- default:
-- break L
-+ return
- }
- lhs = false // no need to try to resolve again
- }
--
-- return x
+@@ -1591,6 +1625,8 @@ func (p *parser) parsePrimaryExpr() (x ast.Expr) {
}
- // If lhs is set and the result is an identifier, it is not resolved.
- func (p *parser) parseUnaryExpr(lhs bool) ast.Expr {
+ func (p *parser) parseUnaryExpr() ast.Expr {
+ defer decNestLev(incNestLev(p))
++
if p.trace {
defer un(trace(p, "UnaryExpr"))
}
-@@ -1609,7 +1641,13 @@ func (p *parser) parseBinaryExpr(lhs bool, prec1 int) ast.Expr {
+@@ -1673,7 +1709,13 @@ func (p *parser) parseBinaryExpr(prec1 int) ast.Expr {
}
- x := p.parseUnaryExpr(lhs)
+ x := p.parseUnaryExpr()
- for {
+ // We track the nesting here rather than at the entry for the function,
+ // since it can iteratively produce a nested output, and we want to
@@ -209,7 +166,7 @@ index 31a7398..29bf774 100644
op, oprec := p.tokPrec()
if oprec < prec1 {
return x
-@@ -1899,6 +1937,8 @@ func (p *parser) parseIfHeader() (init ast.Stmt, cond ast.Expr) {
+@@ -1962,6 +2004,8 @@ func (p *parser) parseIfHeader() (init ast.Stmt, cond ast.Expr) {
}
func (p *parser) parseIfStmt() *ast.IfStmt {
@@ -218,7 +175,7 @@ index 31a7398..29bf774 100644
if p.trace {
defer un(trace(p, "IfStmt"))
}
-@@ -2214,6 +2254,8 @@ func (p *parser) parseForStmt() ast.Stmt {
+@@ -2265,6 +2309,8 @@ func (p *parser) parseForStmt() ast.Stmt {
}
func (p *parser) parseStmt() (s ast.Stmt) {
@@ -228,18 +185,18 @@ index 31a7398..29bf774 100644
defer un(trace(p, "Statement"))
}
diff --git a/src/go/parser/parser_test.go b/src/go/parser/parser_test.go
-index 25a374e..344597d 100644
+index a4f882d3688..1a46c878663 100644
--- a/src/go/parser/parser_test.go
+++ b/src/go/parser/parser_test.go
@@ -10,6 +10,7 @@ import (
"go/ast"
"go/token"
- "os"
+ "io/fs"
+ "runtime"
"strings"
"testing"
)
-@@ -569,3 +570,173 @@ type x int // comment
+@@ -577,3 +578,171 @@ type x int // comment
t.Errorf("got %q, want %q", comment, "// comment")
}
}
@@ -363,8 +320,6 @@ index 25a374e..344597d 100644
+ }
+}
+
-+const maxScopeDepth int = 1e3
-+
+func TestScopeDepthLimit(t *testing.T) {
+ if runtime.GOARCH == "wasm" {
+ t.Skip("causes call stack exhaustion on js/wasm")
@@ -413,6 +368,54 @@ index 25a374e..344597d 100644
+ }
+ }
+}
+diff --git a/src/go/parser/resolver.go b/src/go/parser/resolver.go
+index cf92c7e4f57..f55bdb7f177 100644
+--- a/src/go/parser/resolver.go
++++ b/src/go/parser/resolver.go
+@@ -25,6 +25,7 @@ func resolveFile(file *ast.File, handle *token.File, declErr func(token.Pos, str
+ declErr: declErr,
+ topScope: pkgScope,
+ pkgScope: pkgScope,
++ depth: 1,
+ }
+
+ for _, decl := range file.Decls {
+@@ -53,6 +54,8 @@ func resolveFile(file *ast.File, handle *token.File, declErr func(token.Pos, str
+ file.Unresolved = r.unresolved[0:i]
+ }
+
++const maxScopeDepth int = 1e3
++
+ type resolver struct {
+ handle *token.File
+ declErr func(token.Pos, string)
+@@ -61,6 +64,7 @@ type resolver struct {
+ pkgScope *ast.Scope // pkgScope.Outer == nil
+ topScope *ast.Scope // top-most scope; may be pkgScope
+ unresolved []*ast.Ident // unresolved identifiers
++ depth int // scope depth
+
+ // Label scopes
+ // (maintained by open/close LabelScope)
+@@ -83,6 +87,10 @@ func (r *resolver) sprintf(format string, args ...interface{}) string {
+ }
+
+ func (r *resolver) openScope(pos token.Pos) {
++ r.depth++
++ if r.depth > maxScopeDepth {
++ panic(bailout{pos: pos, msg: "exceeded max scope depth during object resolution"})
++ }
+ if debugResolve {
+ r.dump("opening scope @%v", pos)
+ }
+@@ -90,6 +98,7 @@ func (r *resolver) openScope(pos token.Pos) {
+ }
+
+ func (r *resolver) closeScope() {
++ r.depth--
+ if debugResolve {
+ r.dump("closing scope")
+ }
--
2.30.2
diff --git a/0007-release-branch.go1.15-cmd-go-don-t-lookup-the-path-f.patch b/0007-release-branch.go1.15-cmd-go-don-t-lookup-the-path-f.patch
deleted file mode 100644
index 69747bbd84412a562953978f29d8d7d1502809a6..0000000000000000000000000000000000000000
--- a/0007-release-branch.go1.15-cmd-go-don-t-lookup-the-path-f.patch
+++ /dev/null
@@ -1,208 +0,0 @@
-From 4a48a7d7bda25a844a7e597e96041b55c9f32d4d Mon Sep 17 00:00:00 2001
-From: Jay Conrod
-Date: Fri, 22 Jan 2021 14:27:24 -0500
-Subject: [PATCH 07/44] [release-branch.go1.15] cmd/go: don't lookup the path
- for CC when invoking cgo
-
-Previously, if CC was a path without separators (like gcc or clang),
-we'd look it up in PATH in cmd/go using internal/execabs.LookPath,
-then pass the resolved path to cgo in CC.
-
-This caused a regression: if the directory in PATH containing CC has a
-space, cgo splits it and interprets it as multiple arguments.
-
-With this change, cmd/go no longer resolves CC before invoking
-cgo. cgo does the path lookup on each invocation. This reverts the
-security fix CL 284780, but that was redundant with the addition of
-internal/execabs (CL 955304), which still protects us.
-
-NOTE: This CL includes a related test fix from CL 286292.
-
-Fixes #43860
-
-Change-Id: I65d91a1e303856df8653881eb6e2e75a3bf95c49
-Reviewed-on: https://go-review.googlesource.com/c/go/+/285873
-Trust: Jay Conrod
-Run-TryBot: Jay Conrod
-TryBot-Result: Go Bot
-Reviewed-by: Bryan C. Mills
-(cherry picked from commit a2cef9b544708ecae983ed8836ee2425a28aab68)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/285954
-Run-TryBot: Dmitri Shuralyov
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/4a48a7d7bda25a844a7e597e96041b55c9f32d4d
-
----
- src/cmd/go/internal/work/action.go | 3 -
- src/cmd/go/internal/work/exec.go | 27 ++-------
- src/cmd/go/testdata/script/cgo_path.txt | 12 +++-
- src/cmd/go/testdata/script/cgo_path_space.txt | 56 +++++++++++++++++++
- 4 files changed, 72 insertions(+), 26 deletions(-)
- create mode 100644 src/cmd/go/testdata/script/cgo_path_space.txt
-
-diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go
-index 03ca301bdd..6b5f9e4807 100644
---- a/src/cmd/go/internal/work/action.go
-+++ b/src/cmd/go/internal/work/action.go
-@@ -56,9 +56,6 @@ type Builder struct {
- id sync.Mutex
- toolIDCache map[string]string // tool name -> tool ID
- buildIDCache map[string]string // file name -> build ID
--
-- cgoEnvOnce sync.Once
-- cgoEnvCache []string
- }
-
- // NOTE: Much of Action would not need to be exported if not for test.
-diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
-index f5f9951afa..eb1efd9f82 100644
---- a/src/cmd/go/internal/work/exec.go
-+++ b/src/cmd/go/internal/work/exec.go
-@@ -1081,7 +1081,10 @@ func (b *Builder) vet(a *Action) error {
- }
-
- // TODO(rsc): Why do we pass $GCCGO to go vet?
-- env := b.cgoEnv()
-+ env := b.cCompilerEnv()
-+ if cfg.BuildToolchainName == "gccgo" {
-+ env = append(env, "GCCGO="+BuildToolchain.compiler())
-+ }
-
- p := a.Package
- tool := VetTool
-@@ -2015,24 +2018,6 @@ func (b *Builder) cCompilerEnv() []string {
- return []string{"TERM=dumb"}
- }
-
--// cgoEnv returns environment variables to set when running cgo.
--// Some of these pass through to cgo running the C compiler,
--// so it includes cCompilerEnv.
--func (b *Builder) cgoEnv() []string {
-- b.cgoEnvOnce.Do(func() {
-- cc, err := exec.LookPath(b.ccExe()[0])
-- if err != nil || filepath.Base(cc) == cc { // reject relative path
-- cc = "/missing-cc"
-- }
-- gccgo := GccgoBin
-- if filepath.Base(gccgo) == gccgo { // reject relative path
-- gccgo = "/missing-gccgo"
-- }
-- b.cgoEnvCache = append(b.cCompilerEnv(), "CC="+cc, "GCCGO="+gccgo)
-- })
-- return b.cgoEnvCache
--}
--
- // mkdir makes the named directory.
- func (b *Builder) Mkdir(dir string) error {
- // Make Mkdir(a.Objdir) a no-op instead of an error when a.Objdir == "".
-@@ -2622,7 +2607,7 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo
- // along to the host linker. At this point in the code, cgoLDFLAGS
- // consists of the original $CGO_LDFLAGS (unchecked) and all the
- // flags put together from source code (checked).
-- cgoenv := b.cgoEnv()
-+ cgoenv := b.cCompilerEnv()
- if len(cgoLDFLAGS) > 0 {
- flags := make([]string, len(cgoLDFLAGS))
- for i, f := range cgoLDFLAGS {
-@@ -2843,7 +2828,7 @@ func (b *Builder) dynimport(a *Action, p *load.Package, objdir, importGo, cgoExe
- if p.Standard && p.ImportPath == "runtime/cgo" {
- cgoflags = []string{"-dynlinker"} // record path to dynamic linker
- }
-- return b.run(a, p.Dir, p.ImportPath, b.cgoEnv(), cfg.BuildToolexec, cgoExe, "-dynpackage", p.Name, "-dynimport", dynobj, "-dynout", importGo, cgoflags)
-+ return b.run(a, p.Dir, p.ImportPath, b.cCompilerEnv(), cfg.BuildToolexec, cgoExe, "-dynpackage", p.Name, "-dynimport", dynobj, "-dynout", importGo, cgoflags)
- }
-
- // Run SWIG on all SWIG input files.
-diff --git a/src/cmd/go/testdata/script/cgo_path.txt b/src/cmd/go/testdata/script/cgo_path.txt
-index 0d15998426..3eba71bc15 100644
---- a/src/cmd/go/testdata/script/cgo_path.txt
-+++ b/src/cmd/go/testdata/script/cgo_path.txt
-@@ -1,12 +1,20 @@
- [!cgo] skip
-
-+# Set CC explicitly to something that requires a PATH lookup.
-+# Normally, the default is gcc or clang, but if CC was set during make.bash,
-+# that becomes the default.
-+[exec:clang] env CC=clang
-+[exec:gcc] env CC=gcc
-+[!exec:clang] [!exec:gcc] skip 'Unknown C compiler'
-+
- env GOCACHE=$WORK/gocache # Looking for compile flags, so need a clean cache.
- [!windows] env PATH=.:$PATH
--[!windows] chmod 0777 p/gcc p/clang
-+[!windows] chmod 0755 p/gcc p/clang
- [!windows] exists -exec p/gcc p/clang
- [windows] exists -exec p/gcc.bat p/clang.bat
- ! exists p/bug.txt
--go build -x
-+! go build -x
-+stderr '^cgo: exec (clang|gcc): (clang|gcc) resolves to executable in current directory \(.[/\\](clang|gcc)(.bat)?\)$'
- ! exists p/bug.txt
-
- -- go.mod --
-diff --git a/src/cmd/go/testdata/script/cgo_path_space.txt b/src/cmd/go/testdata/script/cgo_path_space.txt
-new file mode 100644
-index 0000000000..654295dc69
---- /dev/null
-+++ b/src/cmd/go/testdata/script/cgo_path_space.txt
-@@ -0,0 +1,56 @@
-+# Check that if the PATH directory containing the C compiler has a space,
-+# we can still use that compiler with cgo.
-+# Verifies #43808.
-+[!cgo] skip
-+
-+# Set CC explicitly to something that requires a PATH lookup.
-+# Normally, the default is gcc or clang, but if CC was set during make.bash,
-+# that becomes the default.
-+[exec:clang] env CC=clang
-+[exec:gcc] env CC=gcc
-+[!exec:clang] [!exec:gcc] skip 'Unknown C compiler'
-+
-+[!windows] chmod 0755 $WORK/'program files'/clang
-+[!windows] chmod 0755 $WORK/'program files'/gcc
-+[!windows] exists -exec $WORK/'program files'/clang
-+[!windows] exists -exec $WORK/'program files'/gcc
-+[!windows] env PATH=$WORK/'program files':$PATH
-+[windows] exists -exec $WORK/'program files'/gcc.bat
-+[windows] exists -exec $WORK/'program files'/clang.bat
-+[windows] env PATH=$WORK\'program files';%PATH%
-+
-+! exists $WORK/log.txt
-+? go build -x
-+exists $WORK/log.txt
-+rm $WORK/log.txt
-+
-+# TODO(#41400, #43078): when CC is set explicitly, it should be allowed to
-+# contain spaces separating arguments, and it should be possible to quote
-+# arguments with spaces (including the path), as in CGO_CFLAGS and other
-+# variables. For now, this doesn't work.
-+[!windows] env CC=$WORK/'program files'/gcc
-+[windows] env CC=$WORK\'program files'\gcc.bat
-+! go build -x
-+! exists $WORK/log.txt
-+
-+-- go.mod --
-+module m
-+
-+-- m.go --
-+package m
-+
-+// #define X 1
-+import "C"
-+
-+-- $WORK/program files/gcc --
-+#!/bin/sh
-+
-+echo ok >$WORK/log.txt
-+-- $WORK/program files/clang --
-+#!/bin/sh
-+
-+echo ok >$WORK/log.txt
-+-- $WORK/program files/gcc.bat --
-+echo ok >%WORK%\log.txt
-+-- $WORK/program files/clang.bat --
-+echo ok >%WORK%\log.txt
---
-2.27.0
-
diff --git a/0066-release-branch.go1.17-net-http-don-t-strip-whitespac.patch b/0007-release-branch.go1.17-net-http-don-t-strip-whitespac.patch
similarity index 77%
rename from 0066-release-branch.go1.17-net-http-don-t-strip-whitespac.patch
rename to 0007-release-branch.go1.17-net-http-don-t-strip-whitespac.patch
index 3cd89eaf49ea1715cd3b99ed5c91508fc7a9000a..7fdcd6f86e68031ece6523d3aed9973202e91630 100644
--- a/0066-release-branch.go1.17-net-http-don-t-strip-whitespac.patch
+++ b/0007-release-branch.go1.17-net-http-don-t-strip-whitespac.patch
@@ -1,7 +1,7 @@
-From f1da2608e141b54e7c1791220c3493a36863c651 Mon Sep 17 00:00:00 2001
+From 4ad62aecaf57ca3adc11a04bd2113bdbee6249c3 Mon Sep 17 00:00:00 2001
From: Damien Neil
Date: Wed, 1 Jun 2022 11:17:07 -0700
-Subject: [PATCH 03/10] [release-branch.go1.17] net/http: don't strip
+Subject: [PATCH 03/11] [release-branch.go1.17] net/http: don't strip
whitespace from Transfer-Encoding headers
Do not accept "Transfer-Encoding: \rchunked" as a valid TE header
@@ -25,7 +25,7 @@ Run-TryBot: Dmitri Shuralyov
Reviewed-by: Dmitri Shuralyov
TryBot-Result: Gopher Robot
-Conflict: src/net/http/transfer.go
+Conflict: NA
Reference: https://go-review.googlesource.com/c/go/+/415217
---
src/net/http/serve_test.go | 1 +
@@ -33,10 +33,10 @@ Reference: https://go-review.googlesource.com/c/go/+/415217
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go
-index 5f569327782..c3f33a5e403 100644
+index 6394da3bb7c..bfac783e3a9 100644
--- a/src/net/http/serve_test.go
+++ b/src/net/http/serve_test.go
-@@ -6151,6 +6151,7 @@ func TestUnsupportedTransferEncodingsReturn501(t *testing.T) {
+@@ -6189,6 +6189,7 @@ func TestUnsupportedTransferEncodingsReturn501(t *testing.T) {
"fugazi",
"foo-bar",
"unknown",
@@ -45,15 +45,15 @@ index 5f569327782..c3f33a5e403 100644
for _, badTE := range unsupportedTEs {
diff --git a/src/net/http/transfer.go b/src/net/http/transfer.go
-index 50d434b1fb0..75ca7eda294 100644
+index 85c2e5a360d..3894007d306 100644
--- a/src/net/http/transfer.go
+++ b/src/net/http/transfer.go
-@@ -629,7 +629,7 @@ func (t *transferReader) parseTransferEncoding() error {
+@@ -639,7 +639,7 @@ func (t *transferReader) parseTransferEncoding() error {
if len(raw) != 1 {
return &unsupportedTEError{fmt.Sprintf("too many transfer encodings: %q", raw)}
}
-- if strings.ToLower(textproto.TrimString(raw[0])) != "chunked" {
-+ if strings.ToLower(raw[0]) != "chunked" {
+- if !ascii.EqualFold(textproto.TrimString(raw[0]), "chunked") {
++ if !ascii.EqualFold(raw[0], "chunked") {
return &unsupportedTEError{fmt.Sprintf("unsupported transfer encoding: %q", raw[0])}
}
diff --git a/0008-release-branch.go1.15-cmd-link-internal-ld-pe-fix-se.patch b/0008-release-branch.go1.15-cmd-link-internal-ld-pe-fix-se.patch
deleted file mode 100644
index b19737a024cc0b71366c321169b3f5c4982f6d22..0000000000000000000000000000000000000000
--- a/0008-release-branch.go1.15-cmd-link-internal-ld-pe-fix-se.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From aa9b48cd1837644a1555fd7a370800924cef627a Mon Sep 17 00:00:00 2001
-From: Derek Parker
-Date: Wed, 25 Nov 2020 16:31:57 +0000
-Subject: [PATCH 08/44] [release-branch.go1.15] cmd/link/internal/ld/pe: fix
- segfault adding resource section
-
-The resource symbol may have been copied to the mmap'd
-output buffer. If so, certain conditions can cause that
-mmap'd output buffer to be munmap'd before we get a chance
-to use it. To avoid any issues we copy the data to the heap
-when the resource symbol exists.
-
-Fixes #42384
-
-Change-Id: I32ef5420802d7313a3d965b8badfbcfb9f0fba4a
-GitHub-Last-Rev: 7b0f43011d06083ee3e871e48a87847636f738f9
-GitHub-Pull-Request: golang/go#42427
-Reviewed-on: https://go-review.googlesource.com/c/go/+/268018
-Run-TryBot: Carlos Amedee
-TryBot-Result: Go Bot
-Reviewed-by: Russ Cox
-Reviewed-by: Cherry Zhang
-Reviewed-by: Than McIntosh
-Trust: Carlos Amedee
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/aa9b48cd1837644a1555fd7a370800924cef627a
-
----
- src/cmd/link/internal/ld/pe.go | 12 ++++++++++++
- 1 file changed, 12 insertions(+)
-
-diff --git a/src/cmd/link/internal/ld/pe.go b/src/cmd/link/internal/ld/pe.go
-index c9cb25dbe5..5d68ca7d9c 100644
---- a/src/cmd/link/internal/ld/pe.go
-+++ b/src/cmd/link/internal/ld/pe.go
-@@ -1515,6 +1515,18 @@ func Asmbpe(ctxt *Link) {
- case sys.AMD64, sys.I386, sys.ARM:
- }
-
-+ if rsrcsym != 0 {
-+ // The resource symbol may have been copied to the mmap'd
-+ // output buffer. If so, certain conditions can cause that
-+ // mmap'd output buffer to be munmap'd before we get a chance
-+ // to use it. To avoid any issues we copy the data to the heap
-+ // when the resource symbol exists.
-+ rsrc := ctxt.loader.Syms[rsrcsym]
-+ data := make([]byte, len(rsrc.P))
-+ copy(data, rsrc.P)
-+ rsrc.P = data
-+ }
-+
- t := pefile.addSection(".text", int(Segtext.Length), int(Segtext.Length))
- t.characteristics = IMAGE_SCN_CNT_CODE | IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ
- if ctxt.LinkMode == LinkExternal {
---
-2.27.0
-
diff --git a/0067-release-branch.go1.17-encoding-xml-limit-depth-of-ne.patch b/0008-release-branch.go1.17-encoding-xml-limit-depth-of-ne.patch
similarity index 97%
rename from 0067-release-branch.go1.17-encoding-xml-limit-depth-of-ne.patch
rename to 0008-release-branch.go1.17-encoding-xml-limit-depth-of-ne.patch
index a1f3c123fd1ac9204d6b1025ba95fb0226294650..077af1523521e89770af7211afd05a3cf1422ca7 100644
--- a/0067-release-branch.go1.17-encoding-xml-limit-depth-of-ne.patch
+++ b/0008-release-branch.go1.17-encoding-xml-limit-depth-of-ne.patch
@@ -1,7 +1,7 @@
-From ae32eafe7dad2b437e38cf65b60abf4971342569 Mon Sep 17 00:00:00 2001
+From 106c859f68c3137cfa05c433a9b90494db386fda Mon Sep 17 00:00:00 2001
From: Roland Shoemaker
Date: Tue, 29 Mar 2022 15:52:09 -0700
-Subject: [PATCH 04/10] [release-branch.go1.17] encoding/xml: limit depth of
+Subject: [PATCH 04/11] [release-branch.go1.17] encoding/xml: limit depth of
nesting in unmarshal
Prevent exhausting the stack limit when unmarshalling extremely deeply
diff --git a/0009-release-branch.go1.15-cmd-internal-goobj2-fix-buglet.patch b/0009-release-branch.go1.15-cmd-internal-goobj2-fix-buglet.patch
deleted file mode 100644
index 97fea5b30aa0c3b07fe7bb2c871521bcb7a352c2..0000000000000000000000000000000000000000
--- a/0009-release-branch.go1.15-cmd-internal-goobj2-fix-buglet.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From 58dc4452620ebefa75742661c538b8406b213b4a Mon Sep 17 00:00:00 2001
-From: Than McIntosh
-Date: Tue, 15 Dec 2020 15:54:25 -0500
-Subject: [PATCH 09/44] [release-branch.go1.15] cmd/internal/goobj2: fix buglet
- in object file reader
-
-The code in the Go object file reader was casting a pointer to mmaped
-memory into a large array prior to performing a read of the
-relocations section:
-
- return (*[1<<20]Reloc)(unsafe.Pointer(&r.b[off]))[:n:n]
-
-For very large object files, this artificial array isn't large enough
-(that is, there are more than 1048576 relocs to read), so update the
-code to use a larger artifical array size.
-
-Fixes #43214.
-Updates #41621.
-
-Change-Id: Ic047c8aef4f8a3839f2e7e3594bce652ebd6bd5b
-Reviewed-on: https://go-review.googlesource.com/c/go/+/278492
-Run-TryBot: Than McIntosh
-TryBot-Result: Go Bot
-Reviewed-by: Cherry Zhang
-Reviewed-by: Jeremy Faller
-Trust: Than McIntosh
-(cherry picked from commit f4e7a6b905ce60448e506a3f6578d01b60602cdd)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/278673
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/58dc4452620ebefa75742661c538b8406b213b4a
-
----
- src/cmd/internal/goobj2/objfile.go | 9 +++++++--
- 1 file changed, 7 insertions(+), 2 deletions(-)
-
-diff --git a/src/cmd/internal/goobj2/objfile.go b/src/cmd/internal/goobj2/objfile.go
-index 7f728e4f76..aba9b9856e 100644
---- a/src/cmd/internal/goobj2/objfile.go
-+++ b/src/cmd/internal/goobj2/objfile.go
-@@ -379,6 +379,11 @@ func (a *Aux) Write(w *Writer) { w.Bytes(a[:]) }
- // for testing
- func (a *Aux) fromBytes(b []byte) { copy(a[:], b) }
-
-+// Used to construct an artifically large array type when reading an
-+// item from the object file relocs section or aux sym section (needs
-+// to work on 32-bit as well as 64-bit). See issue 41621.
-+const huge = (1<<31 - 1) / RelocSize
-+
- // Referenced symbol name.
- //
- // Serialized format:
-@@ -652,7 +657,7 @@ func (r *Reader) Reloc(i int, j int) *Reloc {
- func (r *Reader) Relocs(i int) []Reloc {
- off := r.RelocOff(i, 0)
- n := r.NReloc(i)
-- return (*[1 << 20]Reloc)(unsafe.Pointer(&r.b[off]))[:n:n]
-+ return (*[huge]Reloc)(unsafe.Pointer(&r.b[off]))[:n:n]
- }
-
- // NAux returns the number of aux symbols of the i-th symbol.
-@@ -678,7 +683,7 @@ func (r *Reader) Aux(i int, j int) *Aux {
- func (r *Reader) Auxs(i int) []Aux {
- off := r.AuxOff(i, 0)
- n := r.NAux(i)
-- return (*[1 << 20]Aux)(unsafe.Pointer(&r.b[off]))[:n:n]
-+ return (*[huge]Aux)(unsafe.Pointer(&r.b[off]))[:n:n]
- }
-
- // DataOff returns the offset of the i-th symbol's data.
---
-2.27.0
-
diff --git a/0068-release-branch.go1.17-encoding-gob-add-a-depth-limit.patch b/0009-release-branch.go1.17-encoding-gob-add-a-depth-limit.patch
similarity index 97%
rename from 0068-release-branch.go1.17-encoding-gob-add-a-depth-limit.patch
rename to 0009-release-branch.go1.17-encoding-gob-add-a-depth-limit.patch
index dbbe26e87e89ac21e1e6b263a0973bd2b830e0d0..13f56a5ce339c494603c9e8c1a7c47bcf8a318f4 100644
--- a/0068-release-branch.go1.17-encoding-gob-add-a-depth-limit.patch
+++ b/0009-release-branch.go1.17-encoding-gob-add-a-depth-limit.patch
@@ -1,7 +1,7 @@
-From 30b474a6578f25ce4e065362bea06f61abe8b7df Mon Sep 17 00:00:00 2001
+From 8747af9a1098e8fa497441be4c4a79a23de31a98 Mon Sep 17 00:00:00 2001
From: Roland Shoemaker
Date: Tue, 7 Jun 2022 13:00:43 -0700
-Subject: [PATCH 05/10] [release-branch.go1.17] encoding/gob: add a depth limit
+Subject: [PATCH 05/11] [release-branch.go1.17] encoding/gob: add a depth limit
for ignored fields
Enforce a nesting limit of 10,000 for ignored fields during decoding
diff --git a/0010-release-branch.go1.15-runtime-don-t-adjust-timer-pp-.patch b/0010-release-branch.go1.15-runtime-don-t-adjust-timer-pp-.patch
deleted file mode 100644
index 8484da4f7e0875fd2453c63e9d406cda2203231e..0000000000000000000000000000000000000000
--- a/0010-release-branch.go1.15-runtime-don-t-adjust-timer-pp-.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-From 3171f483775c7eb8d38b68f53d8fd5078db7f967 Mon Sep 17 00:00:00 2001
-From: Ian Lance Taylor
-Date: Tue, 19 Jan 2021 21:30:36 -0800
-Subject: [PATCH 10/44] [release-branch.go1.15] runtime: don't adjust timer pp
- field in timerWaiting status
-
-Before this CL, the following sequence was possible:
-
-* GC scavenger starts and sets up scavenge.timer
-* GC calls readyForScavenger, but sysmon is sleeping
-* program calls runtime.GOMAXPROCS to shrink number of processors
-* procresize destroys a P, the one that scavenge.timer is on
-* (*pp).destroy calls moveTimers, which gets to the scavenger timer
-* scavenger timer is timerWaiting, and moveTimers clears t.pp
-* sysmon wakes up and calls wakeScavenger
-* wakeScavengers calls stopTimer on scavenger.timer, still timerWaiting
-* stopTimer calls deltimer which loads t.pp, which is still nil
-* stopTimer tries to increment deletedTimers on nil t.pp, and crashes
-
-The point of vulnerability is the time that t.pp is set to nil by
-moveTimers and the time that t.pp is set to non-nil by moveTimers,
-which is a few instructions at most. So it's not likely and in
-particular is quite unlikely on x86. But with a more relaxed memory
-model the area of vulnerability can be somewhat larger. This appears
-to tbe the cause of two builder failures in a few months on linux-mips.
-
-This CL fixes the problem by making moveTimers change the status from
-timerWaiting to timerMoving while t.pp is clear. That will cause
-deltimer to wait until the status is back to timerWaiting, at which
-point t.pp has been set again.
-
-For #43712
-Fixes #43833
-
-Change-Id: I66838319ecfbf15be66c1fac88d9bd40e2295852
-Reviewed-on: https://go-review.googlesource.com/c/go/+/284775
-Trust: Ian Lance Taylor
-Reviewed-by: Michael Knyszek
-Reviewed-by: Michael Pratt
-(cherry picked from commit d2d155d1ae8c704a37f42fd3ebb1f3846f78e4d4)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/287092
-Run-TryBot: Carlos Amedee
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/3171f483775c7eb8d38b68f53d8fd5078db7f967
-
----
- src/runtime/time.go | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/src/runtime/time.go b/src/runtime/time.go
-index fdb5066b24..ec3eae9cca 100644
---- a/src/runtime/time.go
-+++ b/src/runtime/time.go
-@@ -594,8 +594,14 @@ func moveTimers(pp *p, timers []*timer) {
- for {
- switch s := atomic.Load(&t.status); s {
- case timerWaiting:
-+ if !atomic.Cas(&t.status, s, timerMoving) {
-+ continue
-+ }
- t.pp = 0
- doaddtimer(pp, t)
-+ if !atomic.Cas(&t.status, timerMoving, timerWaiting) {
-+ badTimer()
-+ }
- break loop
- case timerModifiedEarlier, timerModifiedLater:
- if !atomic.Cas(&t.status, s, timerMoving) {
---
-2.27.0
-
diff --git a/0010-release-branch.go1.17-io-fs-fix-stack-exhaustion-in-.patch b/0010-release-branch.go1.17-io-fs-fix-stack-exhaustion-in-.patch
new file mode 100644
index 0000000000000000000000000000000000000000..c1943787ed4deeb3a6687cd4fd560c68b9dbac4c
--- /dev/null
+++ b/0010-release-branch.go1.17-io-fs-fix-stack-exhaustion-in-.patch
@@ -0,0 +1,96 @@
+From a8d44d0477f2182563e279da115cbc164d639f33 Mon Sep 17 00:00:00 2001
+From: Julie Qiu
+Date: Thu, 23 Jun 2022 23:17:53 +0000
+Subject: [PATCH 06/11] [release-branch.go1.17] io/fs: fix stack exhaustion in
+ Glob
+
+A limit is added to the number of path separators allowed by an input to
+Glob, to prevent stack exhaustion issues.
+
+Thanks to Juho Nurminen of Mattermost who reported a similar issue in
+path/filepath.
+
+Fixes #53719
+Updates #53415
+Fixes CVE-2022-30630
+
+Change-Id: I5a9d02591fed90cd3d52627f5945f1301e53465d
+Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1497588
+Reviewed-by: Roland Shoemaker
+(cherry picked from commit fdccc5d7bd0f276d0a8de3a818ca844f0bed5d97)
+Reviewed-on: https://go-review.googlesource.com/c/go/+/417072
+Reviewed-by: Heschi Kreinick
+TryBot-Result: Gopher Robot
+Run-TryBot: Michael Knyszek
+
+Conflict: NA
+Reference: https://go-review.googlesource.com/c/go/+/417072
+---
+ src/io/fs/glob.go | 14 ++++++++++++--
+ src/io/fs/glob_test.go | 10 ++++++++++
+ 2 files changed, 22 insertions(+), 2 deletions(-)
+
+diff --git a/src/io/fs/glob.go b/src/io/fs/glob.go
+index 45d9cb61b96..0e529cd05d1 100644
+--- a/src/io/fs/glob.go
++++ b/src/io/fs/glob.go
+@@ -31,6 +31,16 @@ type GlobFS interface {
+ // Otherwise, Glob uses ReadDir to traverse the directory tree
+ // and look for matches for the pattern.
+ func Glob(fsys FS, pattern string) (matches []string, err error) {
++ return globWithLimit(fsys, pattern, 0)
++}
++
++func globWithLimit(fsys FS, pattern string, depth int) (matches []string, err error) {
++ // This limit is added to prevent stack exhaustion issues. See
++ // CVE-2022-30630.
++ const pathSeparatorsLimit = 10000
++ if depth > pathSeparatorsLimit {
++ return nil, path.ErrBadPattern
++ }
+ if fsys, ok := fsys.(GlobFS); ok {
+ return fsys.Glob(pattern)
+ }
+@@ -59,9 +69,9 @@ func Glob(fsys FS, pattern string) (matches []string, err error) {
+ }
+
+ var m []string
+- m, err = Glob(fsys, dir)
++ m, err = globWithLimit(fsys, dir, depth+1)
+ if err != nil {
+- return
++ return nil, err
+ }
+ for _, d := range m {
+ matches, err = glob(fsys, d, file, matches)
+diff --git a/src/io/fs/glob_test.go b/src/io/fs/glob_test.go
+index f19bebed77f..d052eab3713 100644
+--- a/src/io/fs/glob_test.go
++++ b/src/io/fs/glob_test.go
+@@ -8,6 +8,7 @@ import (
+ . "io/fs"
+ "os"
+ "path"
++ "strings"
+ "testing"
+ )
+
+@@ -55,6 +56,15 @@ func TestGlobError(t *testing.T) {
+ }
+ }
+
++func TestCVE202230630(t *testing.T) {
++ // Prior to CVE-2022-30630, a stack exhaustion would occur given a large
++ // number of separators. There is now a limit of 10,000.
++ _, err := Glob(os.DirFS("."), "/*"+strings.Repeat("/", 10001))
++ if err != path.ErrBadPattern {
++ t.Fatalf("Glob returned err=%v, want %v", err, path.ErrBadPattern)
++ }
++}
++
+ // contains reports whether vector contains the string s.
+ func contains(vector []string, s string) bool {
+ for _, elem := range vector {
+--
+2.30.2
+
diff --git a/0011-release-branch.go1.15-runtime-cgo-fix-Android-build-.patch b/0011-release-branch.go1.15-runtime-cgo-fix-Android-build-.patch
deleted file mode 100644
index 9fe1721db43fdd9818b170faee336b9524f35b83..0000000000000000000000000000000000000000
--- a/0011-release-branch.go1.15-runtime-cgo-fix-Android-build-.patch
+++ /dev/null
@@ -1,82 +0,0 @@
-From c3e1c3800bfb56bf1b0c3d696f59f42b16bd4fc2 Mon Sep 17 00:00:00 2001
-From: Elias Naur
-Date: Fri, 25 Dec 2020 11:14:11 +0100
-Subject: [PATCH 11/44] [release-branch.go1.15] runtime/cgo: fix Android build
- with NDK 22
-
-Fixes #43406
-
-Change-Id: I7d2b70098a4ba4dcb325fb0be076043789b86135
-Reviewed-on: https://go-review.googlesource.com/c/go/+/280312
-Run-TryBot: Elias Naur
-TryBot-Result: Go Bot
-Reviewed-by: Ian Lance Taylor
-Trust: Elias Naur
-(cherry picked from commit 1d78139128d6d839d7da0aeb10b3e51b6c7c0749)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/289149
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/c3e1c3800bfb56bf1b0c3d696f59f42b16bd4fc2
-
----
- src/runtime/cgo/gcc_linux_386.c | 2 +-
- src/runtime/cgo/gcc_linux_amd64.c | 2 +-
- src/runtime/cgo/gcc_linux_arm.c | 2 +-
- src/runtime/cgo/gcc_linux_arm64.c | 2 +-
- 4 files changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/src/runtime/cgo/gcc_linux_386.c b/src/runtime/cgo/gcc_linux_386.c
-index ece9f933c5..70c942aeb8 100644
---- a/src/runtime/cgo/gcc_linux_386.c
-+++ b/src/runtime/cgo/gcc_linux_386.c
-@@ -12,7 +12,7 @@ static void *threadentry(void*);
- static void (*setg_gcc)(void*);
-
- // This will be set in gcc_android.c for android-specific customization.
--void (*x_cgo_inittls)(void **tlsg, void **tlsbase);
-+void (*x_cgo_inittls)(void **tlsg, void **tlsbase) __attribute__((common));
-
- void
- x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase)
-diff --git a/src/runtime/cgo/gcc_linux_amd64.c b/src/runtime/cgo/gcc_linux_amd64.c
-index 9134e0df92..f2bf6482cb 100644
---- a/src/runtime/cgo/gcc_linux_amd64.c
-+++ b/src/runtime/cgo/gcc_linux_amd64.c
-@@ -14,7 +14,7 @@ static void* threadentry(void*);
- static void (*setg_gcc)(void*);
-
- // This will be set in gcc_android.c for android-specific customization.
--void (*x_cgo_inittls)(void **tlsg, void **tlsbase);
-+void (*x_cgo_inittls)(void **tlsg, void **tlsbase) __attribute__((common));
-
- void
- x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase)
-diff --git a/src/runtime/cgo/gcc_linux_arm.c b/src/runtime/cgo/gcc_linux_arm.c
-index 61855b96b2..5bc0fee90d 100644
---- a/src/runtime/cgo/gcc_linux_arm.c
-+++ b/src/runtime/cgo/gcc_linux_arm.c
-@@ -10,7 +10,7 @@
-
- static void *threadentry(void*);
-
--void (*x_cgo_inittls)(void **tlsg, void **tlsbase);
-+void (*x_cgo_inittls)(void **tlsg, void **tlsbase) __attribute__((common));
- static void (*setg_gcc)(void*);
-
- void
-diff --git a/src/runtime/cgo/gcc_linux_arm64.c b/src/runtime/cgo/gcc_linux_arm64.c
-index 261c884ac9..17ff274fbb 100644
---- a/src/runtime/cgo/gcc_linux_arm64.c
-+++ b/src/runtime/cgo/gcc_linux_arm64.c
-@@ -12,7 +12,7 @@
-
- static void *threadentry(void*);
-
--void (*x_cgo_inittls)(void **tlsg, void **tlsbase);
-+void (*x_cgo_inittls)(void **tlsg, void **tlsbase) __attribute__((common));
- static void (*setg_gcc)(void*);
-
- void
---
-2.27.0
-
diff --git a/0069-release-branch.go1.17-path-filepath-fix-stack-exhaus.patch b/0011-release-branch.go1.17-path-filepath-fix-stack-exhaus.patch
similarity index 75%
rename from 0069-release-branch.go1.17-path-filepath-fix-stack-exhaus.patch
rename to 0011-release-branch.go1.17-path-filepath-fix-stack-exhaus.patch
index 23a4b6f65dcf0287de7ab65749429febf449abff..661634ac3dabe484b61c160c12218f3fb5a04700 100644
--- a/0069-release-branch.go1.17-path-filepath-fix-stack-exhaus.patch
+++ b/0011-release-branch.go1.17-path-filepath-fix-stack-exhaus.patch
@@ -1,7 +1,7 @@
-From 472c7e454d5d2a6afbc5494d55e0955c4f2a6990 Mon Sep 17 00:00:00 2001
+From 7b98bf3a8711126c532033ca89647f3b743b58ec Mon Sep 17 00:00:00 2001
From: Julie Qiu
Date: Thu, 23 Jun 2022 23:18:56 +0000
-Subject: [PATCH 06/10] [release-branch.go1.17] path/filepath: fix stack
+Subject: [PATCH 07/11] [release-branch.go1.17] path/filepath: fix stack
exhaustion in Glob
A limit is added to the number of path separators allowed by an input to
@@ -25,15 +25,15 @@ Run-TryBot: Michael Knyszek
Conflict: NA
Reference: https://go-review.googlesource.com/c/go/+/417073
---
- src/path/filepath/match.go | 16 +++++++++++++++-
+ src/path/filepath/match.go | 12 +++++++++++-
src/path/filepath/match_test.go | 10 ++++++++++
- 2 files changed, 25 insertions(+), 1 deletion(-)
+ 2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/path/filepath/match.go b/src/path/filepath/match.go
-index 20a334805ba..b6a3b450fe8 100644
+index c77a26952a6..55ed1d75ae1 100644
--- a/src/path/filepath/match.go
+++ b/src/path/filepath/match.go
-@@ -232,6 +232,20 @@ func getEsc(chunk string) (r rune, nchunk string, err error) {
+@@ -241,6 +241,16 @@ func getEsc(chunk string) (r rune, nchunk string, err error) {
// The only possible returned error is ErrBadPattern, when pattern
// is malformed.
func Glob(pattern string) (matches []string, err error) {
@@ -47,14 +47,10 @@ index 20a334805ba..b6a3b450fe8 100644
+ return nil, ErrBadPattern
+ }
+
-+ // Check pattern is well-formed.
-+ if _, err := Match(pattern, ""); err != nil {
-+ return nil, err
-+ }
- if !hasMeta(pattern) {
- if _, err = os.Lstat(pattern); err != nil {
- return nil, nil
-@@ -257,7 +271,7 @@ func Glob(pattern string) (matches []string, err error) {
+ // Check pattern is well-formed.
+ if _, err := Match(pattern, ""); err != nil {
+ return nil, err
+@@ -270,7 +280,7 @@ func Glob(pattern string) (matches []string, err error) {
}
var m []string
@@ -64,10 +60,10 @@ index 20a334805ba..b6a3b450fe8 100644
return
}
diff --git a/src/path/filepath/match_test.go b/src/path/filepath/match_test.go
-index b8657626bc7..c37c812181f 100644
+index 375c41a7e9d..d6282596fed 100644
--- a/src/path/filepath/match_test.go
+++ b/src/path/filepath/match_test.go
-@@ -154,6 +154,16 @@ func TestGlob(t *testing.T) {
+@@ -155,6 +155,16 @@ func TestGlob(t *testing.T) {
}
}
@@ -82,8 +78,8 @@ index b8657626bc7..c37c812181f 100644
+}
+
func TestGlobError(t *testing.T) {
- _, err := Glob("[]")
- if err == nil {
+ bad := []string{`[]`, `nonexist/[]`}
+ for _, pattern := range bad {
--
2.30.2
diff --git a/0070-release-branch.go1.17-encoding-xml-use-iterative-Ski.patch b/0012-release-branch.go1.17-encoding-xml-use-iterative-Ski.patch
similarity index 93%
rename from 0070-release-branch.go1.17-encoding-xml-use-iterative-Ski.patch
rename to 0012-release-branch.go1.17-encoding-xml-use-iterative-Ski.patch
index 622c336bd323ab7f2c8390f38593d9b842820366..9be1eea8260baee823f1d033a0493f36a0efb8e1 100644
--- a/0070-release-branch.go1.17-encoding-xml-use-iterative-Ski.patch
+++ b/0012-release-branch.go1.17-encoding-xml-use-iterative-Ski.patch
@@ -1,7 +1,7 @@
-From a63efc45c908bfd46c60e95956cce499a2c92e44 Mon Sep 17 00:00:00 2001
+From cedbe8f7a1f0d174636e70de68d85499d8025000 Mon Sep 17 00:00:00 2001
From: Roland Shoemaker
Date: Mon, 28 Mar 2022 18:41:26 -0700
-Subject: [PATCH 07/10] [release-branch.go1.17] encoding/xml: use iterative
+Subject: [PATCH 08/11] [release-branch.go1.17] encoding/xml: use iterative
Skip, rather than recursive
Prevents exhausting the stack limit in _incredibly_ deeply nested
diff --git a/0013-release-branch.go1.15-internal-poll-if-copy_file_ran.patch b/0013-release-branch.go1.15-internal-poll-if-copy_file_ran.patch
deleted file mode 100644
index 6aee0f5a52935d641b9226afb7887b5e31cac7d1..0000000000000000000000000000000000000000
--- a/0013-release-branch.go1.15-internal-poll-if-copy_file_ran.patch
+++ /dev/null
@@ -1,102 +0,0 @@
-From 023c46676db26e75d244b1d38ccc4a4b8bfe3eef Mon Sep 17 00:00:00 2001
-From: Ian Lance Taylor
-Date: Sun, 14 Feb 2021 17:14:41 -0800
-Subject: [PATCH 13/44] [release-branch.go1.15] internal/poll: if
- copy_file_range returns 0, assume it failed
-
-On current Linux kernels copy_file_range does not correctly handle
-files in certain special file systems, such as /proc. For those file
-systems it fails to copy any data and returns zero. This breaks Go's
-io.Copy for those files.
-
-Fix the problem by assuming that if copy_file_range returns 0 the
-first time it is called on a file, that that file is not supported.
-In that case fall back to just using read. This will force an extra
-system call when using io.Copy to copy a zero-sized normal file,
-but at least it will work correctly.
-
-For #36817
-For #44272
-Fixes #44273
-
-Change-Id: I02e81872cb70fda0ce5485e2ea712f219132e614
-Reviewed-on: https://go-review.googlesource.com/c/go/+/291989
-Trust: Ian Lance Taylor
-Run-TryBot: Ian Lance Taylor
-TryBot-Result: Go Bot
-Reviewed-by: Russ Cox
-(cherry picked from commit 30641e36aa5b547eee48565caa3078b0a2e7c185)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/292289
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/023c46676db26e75d244b1d38ccc4a4b8bfe3eef
-
----
- src/internal/poll/copy_file_range_linux.go | 10 ++++++-
- src/os/readfrom_linux_test.go | 32 ++++++++++++++++++++++
- 2 files changed, 41 insertions(+), 1 deletion(-)
-
-diff --git a/src/internal/poll/copy_file_range_linux.go b/src/internal/poll/copy_file_range_linux.go
-index fc34aef4cb..01b242a4ea 100644
---- a/src/internal/poll/copy_file_range_linux.go
-+++ b/src/internal/poll/copy_file_range_linux.go
-@@ -112,7 +112,15 @@ func CopyFileRange(dst, src *FD, remain int64) (written int64, handled bool, err
- return 0, false, nil
- case nil:
- if n == 0 {
-- // src is at EOF, which means we are done.
-+ // If we did not read any bytes at all,
-+ // then this file may be in a file system
-+ // where copy_file_range silently fails.
-+ // https://lore.kernel.org/linux-fsdevel/20210126233840.GG4626@dread.disaster.area/T/#m05753578c7f7882f6e9ffe01f981bc223edef2b0
-+ if written == 0 {
-+ return 0, false, nil
-+ }
-+ // Otherwise src is at EOF, which means
-+ // we are done.
- return written, true, nil
- }
- remain -= n
-diff --git a/src/os/readfrom_linux_test.go b/src/os/readfrom_linux_test.go
-index 00faf39fe5..aa3f050667 100644
---- a/src/os/readfrom_linux_test.go
-+++ b/src/os/readfrom_linux_test.go
-@@ -361,3 +361,35 @@ func (h *copyFileRangeHook) install() {
- func (h *copyFileRangeHook) uninstall() {
- *PollCopyFileRangeP = h.original
- }
-+
-+// On some kernels copy_file_range fails on files in /proc.
-+func TestProcCopy(t *testing.T) {
-+ const cmdlineFile = "/proc/self/cmdline"
-+ cmdline, err := ioutil.ReadFile(cmdlineFile)
-+ if err != nil {
-+ t.Skipf("can't read /proc file: %v", err)
-+ }
-+ in, err := Open(cmdlineFile)
-+ if err != nil {
-+ t.Fatal(err)
-+ }
-+ defer in.Close()
-+ outFile := filepath.Join(t.TempDir(), "cmdline")
-+ out, err := Create(outFile)
-+ if err != nil {
-+ t.Fatal(err)
-+ }
-+ if _, err := io.Copy(out, in); err != nil {
-+ t.Fatal(err)
-+ }
-+ if err := out.Close(); err != nil {
-+ t.Fatal(err)
-+ }
-+ copy, err := ioutil.ReadFile(outFile)
-+ if err != nil {
-+ t.Fatal(err)
-+ }
-+ if !bytes.Equal(cmdline, copy) {
-+ t.Errorf("copy of %q got %q want %q\n", cmdlineFile, copy, cmdline)
-+ }
-+}
---
-2.27.0
-
diff --git a/0071-release-branch.go1.17-compress-gzip-fix-stack-exhaus.patch b/0013-release-branch.go1.17-compress-gzip-fix-stack-exhaus.patch
similarity index 94%
rename from 0071-release-branch.go1.17-compress-gzip-fix-stack-exhaus.patch
rename to 0013-release-branch.go1.17-compress-gzip-fix-stack-exhaus.patch
index a201e00e7b34122ba351408292abd096aacb0a37..7a54a71ea1789a38b6e07405b4c2d47766b75f08 100644
--- a/0071-release-branch.go1.17-compress-gzip-fix-stack-exhaus.patch
+++ b/0013-release-branch.go1.17-compress-gzip-fix-stack-exhaus.patch
@@ -1,7 +1,7 @@
-From 10531e040d8ed73f51032a7d75c708ca07b638ff Mon Sep 17 00:00:00 2001
+From 8a445abc7f7e2ed41112f176a169b97859c8d425 Mon Sep 17 00:00:00 2001
From: Tatiana Bradley
Date: Fri, 6 May 2022 11:25:06 -0400
-Subject: [PATCH 08/10] [release-branch.go1.17] compress/gzip: fix stack
+Subject: [PATCH 09/11] [release-branch.go1.17] compress/gzip: fix stack
exhaustion bug in Reader.Read
Replace recursion with iteration in Reader.Read to avoid stack
@@ -105,10 +105,10 @@ index 924bce10b7c..237b2b928bf 100644
// Close closes the Reader. It does not close the underlying io.Reader.
diff --git a/src/compress/gzip/gunzip_test.go b/src/compress/gzip/gunzip_test.go
-index 1b014041692..95220ae82d9 100644
+index 17c23e8a9be..6fe8ddcf558 100644
--- a/src/compress/gzip/gunzip_test.go
+++ b/src/compress/gzip/gunzip_test.go
-@@ -516,3 +516,19 @@ func TestTruncatedStreams(t *testing.T) {
+@@ -515,3 +515,19 @@ func TestTruncatedStreams(t *testing.T) {
}
}
}
diff --git a/0014-release-branch.go1.15-internal-poll-netpollcheckerr-.patch b/0014-release-branch.go1.15-internal-poll-netpollcheckerr-.patch
deleted file mode 100644
index 4a9859a80400caf8876cd90f1feb10bd391ac4f1..0000000000000000000000000000000000000000
--- a/0014-release-branch.go1.15-internal-poll-netpollcheckerr-.patch
+++ /dev/null
@@ -1,166 +0,0 @@
-From 30357d6ef6513b18fade686a629ab8d49987260f Mon Sep 17 00:00:00 2001
-From: Wei Fu
-Date: Sun, 24 Jan 2021 18:21:06 +0800
-Subject: [PATCH 14/44] [release-branch.go1.15] internal/poll: netpollcheckerr
- before sendfile
-
-In net/http package, the ServeContent/ServeFile doesn't check the I/O
-timeout error from chunkWriter or *net.TCPConn, which means that both
-HTTP status and headers might be missing when WriteTimeout happens. If
-the poll.SendFile() doesn't check the *poll.FD state before sending
-data, the client will only receive the response body with status and
-report "malformed http response/status code".
-
-This patch is to enable netpollcheckerr before sendfile, which should
-align with normal *poll.FD.Write() and Splice().
-
-For #43822
-Fixes #44294
-
-Change-Id: I32517e3f261bab883a58b577b813ef189214b954
-Reviewed-on: https://go-review.googlesource.com/c/go/+/285914
-Reviewed-by: Emmanuel Odeke
-Trust: Emmanuel Odeke
-Trust: Bryan C. Mills
-Run-TryBot: Emmanuel Odeke
-(cherry picked from commit f0d23c9dbb2142b975fa8fb13a57213d0c15bdd1)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/296530
-Trust: Ian Lance Taylor
-Run-TryBot: Ian Lance Taylor
-TryBot-Result: Go Bot
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/30357d6ef6513b18fade686a629ab8d49987260f
-
----
- src/internal/poll/sendfile_bsd.go | 4 ++
- src/internal/poll/sendfile_linux.go | 3 ++
- src/internal/poll/sendfile_solaris.go | 3 ++
- src/net/sendfile_test.go | 64 +++++++++++++++++++++++++++
- 4 files changed, 74 insertions(+)
-
-diff --git a/src/internal/poll/sendfile_bsd.go b/src/internal/poll/sendfile_bsd.go
-index a24e41dcaa..66005a9f5c 100644
---- a/src/internal/poll/sendfile_bsd.go
-+++ b/src/internal/poll/sendfile_bsd.go
-@@ -18,6 +18,10 @@ func SendFile(dstFD *FD, src int, pos, remain int64) (int64, error) {
- return 0, err
- }
- defer dstFD.writeUnlock()
-+ if err := dstFD.pd.prepareWrite(dstFD.isFile); err != nil {
-+ return 0, err
-+ }
-+
- dst := int(dstFD.Sysfd)
- var written int64
- var err error
-diff --git a/src/internal/poll/sendfile_linux.go b/src/internal/poll/sendfile_linux.go
-index d64283007d..d6442e8666 100644
---- a/src/internal/poll/sendfile_linux.go
-+++ b/src/internal/poll/sendfile_linux.go
-@@ -16,6 +16,9 @@ func SendFile(dstFD *FD, src int, remain int64) (int64, error) {
- return 0, err
- }
- defer dstFD.writeUnlock()
-+ if err := dstFD.pd.prepareWrite(dstFD.isFile); err != nil {
-+ return 0, err
-+ }
-
- dst := int(dstFD.Sysfd)
- var written int64
-diff --git a/src/internal/poll/sendfile_solaris.go b/src/internal/poll/sendfile_solaris.go
-index 762992e9eb..748c85131e 100644
---- a/src/internal/poll/sendfile_solaris.go
-+++ b/src/internal/poll/sendfile_solaris.go
-@@ -20,6 +20,9 @@ func SendFile(dstFD *FD, src int, pos, remain int64) (int64, error) {
- return 0, err
- }
- defer dstFD.writeUnlock()
-+ if err := dstFD.pd.prepareWrite(dstFD.isFile); err != nil {
-+ return 0, err
-+ }
-
- dst := int(dstFD.Sysfd)
- var written int64
-diff --git a/src/net/sendfile_test.go b/src/net/sendfile_test.go
-index 13842a1261..0e344b3649 100644
---- a/src/net/sendfile_test.go
-+++ b/src/net/sendfile_test.go
-@@ -10,6 +10,7 @@ import (
- "bytes"
- "crypto/sha256"
- "encoding/hex"
-+ "errors"
- "fmt"
- "io"
- "io/ioutil"
-@@ -314,3 +315,66 @@ func TestSendfilePipe(t *testing.T) {
-
- wg.Wait()
- }
-+
-+// Issue 43822: tests that returns EOF when conn write timeout.
-+func TestSendfileOnWriteTimeoutExceeded(t *testing.T) {
-+ ln, err := newLocalListener("tcp")
-+ if err != nil {
-+ t.Fatal(err)
-+ }
-+ defer ln.Close()
-+
-+ errc := make(chan error, 1)
-+ go func(ln Listener) (retErr error) {
-+ defer func() {
-+ errc <- retErr
-+ close(errc)
-+ }()
-+
-+ conn, err := ln.Accept()
-+ if err != nil {
-+ return err
-+ }
-+ defer conn.Close()
-+
-+ // Set the write deadline in the past(1h ago). It makes
-+ // sure that it is always write timeout.
-+ if err := conn.SetWriteDeadline(time.Now().Add(-1 * time.Hour)); err != nil {
-+ return err
-+ }
-+
-+ f, err := os.Open(newton)
-+ if err != nil {
-+ return err
-+ }
-+ defer f.Close()
-+
-+ _, err = io.Copy(conn, f)
-+ if errors.Is(err, os.ErrDeadlineExceeded) {
-+ return nil
-+ }
-+
-+ if err == nil {
-+ err = fmt.Errorf("expected ErrDeadlineExceeded, but got nil")
-+ }
-+ return err
-+ }(ln)
-+
-+ conn, err := Dial("tcp", ln.Addr().String())
-+ if err != nil {
-+ t.Fatal(err)
-+ }
-+ defer conn.Close()
-+
-+ n, err := io.Copy(ioutil.Discard, conn)
-+ if err != nil {
-+ t.Fatalf("expected nil error, but got %v", err)
-+ }
-+ if n != 0 {
-+ t.Fatalf("expected receive zero, but got %d byte(s)", n)
-+ }
-+
-+ if err := <-errc; err != nil {
-+ t.Fatal(err)
-+ }
-+}
---
-2.27.0
-
diff --git a/0072-release-branch.go1.17-crypto-tls-randomly-generate-t.patch b/0014-release-branch.go1.17-crypto-tls-randomly-generate-t.patch
similarity index 89%
rename from 0072-release-branch.go1.17-crypto-tls-randomly-generate-t.patch
rename to 0014-release-branch.go1.17-crypto-tls-randomly-generate-t.patch
index 244642451f25bd128d45a025de04d0a08eb3f825..f8f418a62b7f0a81fcd8bd8ae61ed498bf433228 100644
--- a/0072-release-branch.go1.17-crypto-tls-randomly-generate-t.patch
+++ b/0014-release-branch.go1.17-crypto-tls-randomly-generate-t.patch
@@ -1,7 +1,7 @@
-From 251fa2dcc814ef51816245336fd1884239dd002a Mon Sep 17 00:00:00 2001
+From b2815a72bef3f829c5ac7735feddb034f5501cc0 Mon Sep 17 00:00:00 2001
From: Tatiana Bradley
Date: Thu, 12 May 2022 14:58:29 -0400
-Subject: [PATCH 09/10] [release-branch.go1.17] crypto/tls: randomly generate
+Subject: [PATCH 10/11] [release-branch.go1.17] crypto/tls: randomly generate
ticket_age_add
As required by RFC 8446, section 4.6.1, ticket_age_add now holds a
@@ -33,10 +33,10 @@ Reference: https://go-review.googlesource.com/c/go/+/408574
1 file changed, 14 insertions(+)
diff --git a/src/crypto/tls/handshake_server_tls13.go b/src/crypto/tls/handshake_server_tls13.go
-index 92d55e0293a..fcea739b9a9 100644
+index 08251b84def..6aa52698a3a 100644
--- a/src/crypto/tls/handshake_server_tls13.go
+++ b/src/crypto/tls/handshake_server_tls13.go
-@@ -9,6 +9,7 @@ import (
+@@ -10,6 +10,7 @@ import (
"crypto"
"crypto/hmac"
"crypto/rsa"
@@ -44,7 +44,7 @@ index 92d55e0293a..fcea739b9a9 100644
"errors"
"hash"
"io"
-@@ -742,6 +743,19 @@ func (hs *serverHandshakeStateTLS13) sendSessionTickets() error {
+@@ -741,6 +742,19 @@ func (hs *serverHandshakeStateTLS13) sendSessionTickets() error {
}
m.lifetime = uint32(maxSessionTicketLifetime / time.Second)
diff --git a/0015-release-branch.go1.15-cmd-compile-do-not-assume-TST-.patch b/0015-release-branch.go1.15-cmd-compile-do-not-assume-TST-.patch
deleted file mode 100644
index ab3e6dac0cc88ace5fcf0929ec6569a1b8e06cdb..0000000000000000000000000000000000000000
--- a/0015-release-branch.go1.15-cmd-compile-do-not-assume-TST-.patch
+++ /dev/null
@@ -1,1281 +0,0 @@
-From d9b4ef591c2b058004545eccf10a538aa7597adb Mon Sep 17 00:00:00 2001
-From: "Jason A. Donenfeld"
-Date: Mon, 30 Nov 2020 10:41:46 +0100
-Subject: [PATCH 15/44] [release-branch.go1.15] cmd/compile: do not assume TST
- and TEQ set V on arm
-
-These replacement rules assume that TST and TEQ set V. But TST and
-TEQ do not set V. This is a problem because instructions like LT are
-actually checking for N!=V. But with TST and TEQ not setting V, LT
-doesn't do anything meaningful. It's possible to construct trivial
-miscompilations from this, such as:
-
- package main
-
- var x = [4]int32{-0x7fffffff, 0x7fffffff, 2, 4}
-
- func main() {
- if x[0] > x[1] {
- panic("fail 1")
- }
- if x[2]&x[3] < 0 {
- panic("fail 2") // Fails here
- }
- }
-
-That first comparison sets V, via the CMP that subtracts the values
-causing the overflow. Then the second comparison operation thinks that
-it uses the result of TST, when it actually uses the V from CMP.
-
-Before this fix:
-
- TST R0, R1
- BLT loc_6C164
-
-After this fix:
-
- TST R0, R1
- BMI loc_6C164
-
-The BMI instruction checks the N flag, which TST sets. This commit
-fixes the issue by using [LG][TE]noov instead of vanilla [LG][TE], and
-also adds a test case for the direct issue.
-
-Updates #42876.
-Fixes #42930.
-
-Change-Id: I13c62c88d18574247ad002b671b38d2d0b0fc6fa
-Reviewed-on: https://go-review.googlesource.com/c/go/+/282432
-Trust: Jason A. Donenfeld
-Run-TryBot: Jason A. Donenfeld
-TryBot-Result: Go Bot
-Reviewed-by: Cherry Zhang
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/d9b4ef591c2b058004545eccf10a538aa7597adb
-
----
- src/cmd/compile/internal/ssa/gen/ARM.rules | 128 ++++-----
- src/cmd/compile/internal/ssa/rewriteARM.go | 306 ++++++++++-----------
- test/fixedbugs/issue42876.go | 18 ++
- 3 files changed, 235 insertions(+), 217 deletions(-)
- create mode 100644 test/fixedbugs/issue42876.go
-
-diff --git a/src/cmd/compile/internal/ssa/gen/ARM.rules b/src/cmd/compile/internal/ssa/gen/ARM.rules
-index ab8bd0e81e..c69084a701 100644
---- a/src/cmd/compile/internal/ssa/gen/ARM.rules
-+++ b/src/cmd/compile/internal/ssa/gen/ARM.rules
-@@ -1369,38 +1369,38 @@
- (LE (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (CMNshiftLLreg x y z) yes no)
- (LE (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (CMNshiftRLreg x y z) yes no)
- (LE (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LEnoov (CMNshiftRAreg x y z) yes no)
--(LT (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (LT (TST x y) yes no)
--(LT (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (LT (TSTconst [c] x) yes no)
--(LT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (LT (TSTshiftLL x y [c]) yes no)
--(LT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (LT (TSTshiftRL x y [c]) yes no)
--(LT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (LT (TSTshiftRA x y [c]) yes no)
--(LT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LT (TSTshiftLLreg x y z) yes no)
--(LT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LT (TSTshiftRLreg x y z) yes no)
--(LT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LT (TSTshiftRAreg x y z) yes no)
--(LE (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (LE (TST x y) yes no)
--(LE (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (LE (TSTconst [c] x) yes no)
--(LE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (LE (TSTshiftLL x y [c]) yes no)
--(LE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (LE (TSTshiftRL x y [c]) yes no)
--(LE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (LE (TSTshiftRA x y [c]) yes no)
--(LE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LE (TSTshiftLLreg x y z) yes no)
--(LE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LE (TSTshiftRLreg x y z) yes no)
--(LE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LE (TSTshiftRAreg x y z) yes no)
--(LT (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (LT (TEQ x y) yes no)
--(LT (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (LT (TEQconst [c] x) yes no)
--(LT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (LT (TEQshiftLL x y [c]) yes no)
--(LT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (LT (TEQshiftRL x y [c]) yes no)
--(LT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (LT (TEQshiftRA x y [c]) yes no)
--(LT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (LT (TEQshiftLLreg x y z) yes no)
--(LT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (LT (TEQshiftRLreg x y z) yes no)
--(LT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (LT (TEQshiftRAreg x y z) yes no)
--(LE (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (LE (TEQ x y) yes no)
--(LE (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (LE (TEQconst [c] x) yes no)
--(LE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (LE (TEQshiftLL x y [c]) yes no)
--(LE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (LE (TEQshiftRL x y [c]) yes no)
--(LE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (LE (TEQshiftRA x y [c]) yes no)
--(LE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (LE (TEQshiftLLreg x y z) yes no)
--(LE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (LE (TEQshiftRLreg x y z) yes no)
--(LE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (LE (TEQshiftRAreg x y z) yes no)
-+(LT (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (LTnoov (TST x y) yes no)
-+(LT (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (LTnoov (TSTconst [c] x) yes no)
-+(LT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (LTnoov (TSTshiftLL x y [c]) yes no)
-+(LT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (LTnoov (TSTshiftRL x y [c]) yes no)
-+(LT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (LTnoov (TSTshiftRA x y [c]) yes no)
-+(LT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TSTshiftLLreg x y z) yes no)
-+(LT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TSTshiftRLreg x y z) yes no)
-+(LT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TSTshiftRAreg x y z) yes no)
-+(LE (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (LEnoov (TST x y) yes no)
-+(LE (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (LEnoov (TSTconst [c] x) yes no)
-+(LE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (LEnoov (TSTshiftLL x y [c]) yes no)
-+(LE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (LEnoov (TSTshiftRL x y [c]) yes no)
-+(LE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (LEnoov (TSTshiftRA x y [c]) yes no)
-+(LE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TSTshiftLLreg x y z) yes no)
-+(LE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TSTshiftRLreg x y z) yes no)
-+(LE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TSTshiftRAreg x y z) yes no)
-+(LT (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (LTnoov (TEQ x y) yes no)
-+(LT (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (LTnoov (TEQconst [c] x) yes no)
-+(LT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (LTnoov (TEQshiftLL x y [c]) yes no)
-+(LT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (LTnoov (TEQshiftRL x y [c]) yes no)
-+(LT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (LTnoov (TEQshiftRA x y [c]) yes no)
-+(LT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TEQshiftLLreg x y z) yes no)
-+(LT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TEQshiftRLreg x y z) yes no)
-+(LT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TEQshiftRAreg x y z) yes no)
-+(LE (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (LEnoov (TEQ x y) yes no)
-+(LE (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (LEnoov (TEQconst [c] x) yes no)
-+(LE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (LEnoov (TEQshiftLL x y [c]) yes no)
-+(LE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (LEnoov (TEQshiftRL x y [c]) yes no)
-+(LE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (LEnoov (TEQshiftRA x y [c]) yes no)
-+(LE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TEQshiftLLreg x y z) yes no)
-+(LE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TEQshiftRLreg x y z) yes no)
-+(LE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TEQshiftRAreg x y z) yes no)
- (GT (CMPconst [0] l:(SUB x y)) yes no) && l.Uses==1 -> (GTnoov (CMP x y) yes no)
- (GT (CMPconst [0] l:(MULS x y a)) yes no) && l.Uses==1 -> (GTnoov (CMP a (MUL x y)) yes no)
- (GT (CMPconst [0] l:(SUBconst [c] x)) yes no) && l.Uses==1 -> (GTnoov (CMPconst [c] x) yes no)
-@@ -1436,39 +1436,39 @@
- (GE (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (CMNshiftLLreg x y z) yes no)
- (GE (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (CMNshiftRLreg x y z) yes no)
- (GE (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GEnoov (CMNshiftRAreg x y z) yes no)
--(GT (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (GT (TST x y) yes no)
- (GT (CMPconst [0] l:(MULA x y a)) yes no) && l.Uses==1 -> (GTnoov (CMN a (MUL x y)) yes no)
--(GT (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (GT (TSTconst [c] x) yes no)
--(GT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (GT (TSTshiftLL x y [c]) yes no)
--(GT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (GT (TSTshiftRL x y [c]) yes no)
--(GT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (GT (TSTshiftRA x y [c]) yes no)
--(GT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GT (TSTshiftLLreg x y z) yes no)
--(GT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GT (TSTshiftRLreg x y z) yes no)
--(GT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GT (TSTshiftRAreg x y z) yes no)
--(GE (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (GE (TST x y) yes no)
--(GE (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (GE (TSTconst [c] x) yes no)
--(GE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (GE (TSTshiftLL x y [c]) yes no)
--(GE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (GE (TSTshiftRL x y [c]) yes no)
--(GE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (GE (TSTshiftRA x y [c]) yes no)
--(GE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GE (TSTshiftLLreg x y z) yes no)
--(GE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GE (TSTshiftRLreg x y z) yes no)
--(GE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GE (TSTshiftRAreg x y z) yes no)
--(GT (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (GT (TEQ x y) yes no)
--(GT (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (GT (TEQconst [c] x) yes no)
--(GT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (GT (TEQshiftLL x y [c]) yes no)
--(GT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (GT (TEQshiftRL x y [c]) yes no)
--(GT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (GT (TEQshiftRA x y [c]) yes no)
--(GT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (GT (TEQshiftLLreg x y z) yes no)
--(GT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (GT (TEQshiftRLreg x y z) yes no)
--(GT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (GT (TEQshiftRAreg x y z) yes no)
--(GE (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (GE (TEQ x y) yes no)
--(GE (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (GE (TEQconst [c] x) yes no)
--(GE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (GE (TEQshiftLL x y [c]) yes no)
--(GE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (GE (TEQshiftRL x y [c]) yes no)
--(GE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (GE (TEQshiftRA x y [c]) yes no)
--(GE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (GE (TEQshiftLLreg x y z) yes no)
--(GE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (GE (TEQshiftRLreg x y z) yes no)
--(GE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (GE (TEQshiftRAreg x y z) yes no)
-+(GT (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (GTnoov (TST x y) yes no)
-+(GT (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (GTnoov (TSTconst [c] x) yes no)
-+(GT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (GTnoov (TSTshiftLL x y [c]) yes no)
-+(GT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (GTnoov (TSTshiftRL x y [c]) yes no)
-+(GT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (GTnoov (TSTshiftRA x y [c]) yes no)
-+(GT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TSTshiftLLreg x y z) yes no)
-+(GT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TSTshiftRLreg x y z) yes no)
-+(GT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TSTshiftRAreg x y z) yes no)
-+(GE (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (GEnoov (TST x y) yes no)
-+(GE (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (GEnoov (TSTconst [c] x) yes no)
-+(GE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (GEnoov (TSTshiftLL x y [c]) yes no)
-+(GE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (GEnoov (TSTshiftRL x y [c]) yes no)
-+(GE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (GEnoov (TSTshiftRA x y [c]) yes no)
-+(GE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TSTshiftLLreg x y z) yes no)
-+(GE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TSTshiftRLreg x y z) yes no)
-+(GE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TSTshiftRAreg x y z) yes no)
-+(GT (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (GTnoov (TEQ x y) yes no)
-+(GT (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (GTnoov (TEQconst [c] x) yes no)
-+(GT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (GTnoov (TEQshiftLL x y [c]) yes no)
-+(GT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (GTnoov (TEQshiftRL x y [c]) yes no)
-+(GT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (GTnoov (TEQshiftRA x y [c]) yes no)
-+(GT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TEQshiftLLreg x y z) yes no)
-+(GT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TEQshiftRLreg x y z) yes no)
-+(GT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TEQshiftRAreg x y z) yes no)
-+(GE (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (GEnoov (TEQ x y) yes no)
-+(GE (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (GEnoov (TEQconst [c] x) yes no)
-+(GE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (GEnoov (TEQshiftLL x y [c]) yes no)
-+(GE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (GEnoov (TEQshiftRL x y [c]) yes no)
-+(GE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (GEnoov (TEQshiftRA x y [c]) yes no)
-+(GE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TEQshiftLLreg x y z) yes no)
-+(GE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TEQshiftRLreg x y z) yes no)
-+(GE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TEQshiftRAreg x y z) yes no)
-
- (MOVBUload [off] {sym} (SB) _) && symIsRO(sym) -> (MOVWconst [int64(read8(sym, off))])
- (MOVHUload [off] {sym} (SB) _) && symIsRO(sym) -> (MOVWconst [int64(read16(sym, off, config.ctxt.Arch.ByteOrder))])
-diff --git a/src/cmd/compile/internal/ssa/rewriteARM.go b/src/cmd/compile/internal/ssa/rewriteARM.go
-index f55e542505..07653b78f8 100644
---- a/src/cmd/compile/internal/ssa/rewriteARM.go
-+++ b/src/cmd/compile/internal/ssa/rewriteARM.go
-@@ -17278,7 +17278,7 @@ func rewriteBlockARM(b *Block) bool {
- }
- // match: (GE (CMPconst [0] l:(AND x y)) yes no)
- // cond: l.Uses==1
-- // result: (GE (TST x y) yes no)
-+ // result: (GEnoov (TST x y) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17299,14 +17299,14 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags)
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- break
- }
- // match: (GE (CMPconst [0] l:(ANDconst [c] x)) yes no)
- // cond: l.Uses==1
-- // result: (GE (TSTconst [c] x) yes no)
-+ // result: (GEnoov (TSTconst [c] x) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17324,12 +17324,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg(x)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- // match: (GE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (GE (TSTshiftLL x y [c]) yes no)
-+ // result: (GEnoov (TSTshiftLL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17348,12 +17348,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- // match: (GE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (GE (TSTshiftRL x y [c]) yes no)
-+ // result: (GEnoov (TSTshiftRL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17372,12 +17372,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- // match: (GE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (GE (TSTshiftRA x y [c]) yes no)
-+ // result: (GEnoov (TSTshiftRA x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17396,12 +17396,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- // match: (GE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (GE (TSTshiftLLreg x y z) yes no)
-+ // result: (GEnoov (TSTshiftLLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17419,12 +17419,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- // match: (GE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (GE (TSTshiftRLreg x y z) yes no)
-+ // result: (GEnoov (TSTshiftRLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17442,12 +17442,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- // match: (GE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (GE (TSTshiftRAreg x y z) yes no)
-+ // result: (GEnoov (TSTshiftRAreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17465,12 +17465,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- // match: (GE (CMPconst [0] l:(XOR x y)) yes no)
- // cond: l.Uses==1
-- // result: (GE (TEQ x y) yes no)
-+ // result: (GEnoov (TEQ x y) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17491,14 +17491,14 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags)
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- break
- }
- // match: (GE (CMPconst [0] l:(XORconst [c] x)) yes no)
- // cond: l.Uses==1
-- // result: (GE (TEQconst [c] x) yes no)
-+ // result: (GEnoov (TEQconst [c] x) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17516,12 +17516,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg(x)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- // match: (GE (CMPconst [0] l:(XORshiftLL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (GE (TEQshiftLL x y [c]) yes no)
-+ // result: (GEnoov (TEQshiftLL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17540,12 +17540,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- // match: (GE (CMPconst [0] l:(XORshiftRL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (GE (TEQshiftRL x y [c]) yes no)
-+ // result: (GEnoov (TEQshiftRL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17564,12 +17564,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- // match: (GE (CMPconst [0] l:(XORshiftRA x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (GE (TEQshiftRA x y [c]) yes no)
-+ // result: (GEnoov (TEQshiftRA x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17588,12 +17588,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- // match: (GE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (GE (TEQshiftLLreg x y z) yes no)
-+ // result: (GEnoov (TEQshiftLLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17611,12 +17611,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- // match: (GE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (GE (TEQshiftRLreg x y z) yes no)
-+ // result: (GEnoov (TEQshiftRLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17634,12 +17634,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- // match: (GE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (GE (TEQshiftRAreg x y z) yes no)
-+ // result: (GEnoov (TEQshiftRAreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -17657,7 +17657,7 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMGE, v0)
-+ b.resetWithControl(BlockARMGEnoov, v0)
- return true
- }
- case BlockARMGEnoov:
-@@ -18131,9 +18131,34 @@ func rewriteBlockARM(b *Block) bool {
- b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
-+ // match: (GT (CMPconst [0] l:(MULA x y a)) yes no)
-+ // cond: l.Uses==1
-+ // result: (GTnoov (CMN a (MUL x y)) yes no)
-+ for b.Controls[0].Op == OpARMCMPconst {
-+ v_0 := b.Controls[0]
-+ if v_0.AuxInt != 0 {
-+ break
-+ }
-+ l := v_0.Args[0]
-+ if l.Op != OpARMMULA {
-+ break
-+ }
-+ a := l.Args[2]
-+ x := l.Args[0]
-+ y := l.Args[1]
-+ if !(l.Uses == 1) {
-+ break
-+ }
-+ v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags)
-+ v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type)
-+ v1.AddArg2(x, y)
-+ v0.AddArg2(a, v1)
-+ b.resetWithControl(BlockARMGTnoov, v0)
-+ return true
-+ }
- // match: (GT (CMPconst [0] l:(AND x y)) yes no)
- // cond: l.Uses==1
-- // result: (GT (TST x y) yes no)
-+ // result: (GTnoov (TST x y) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18154,39 +18179,14 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags)
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- break
- }
-- // match: (GT (CMPconst [0] l:(MULA x y a)) yes no)
-- // cond: l.Uses==1
-- // result: (GTnoov (CMN a (MUL x y)) yes no)
-- for b.Controls[0].Op == OpARMCMPconst {
-- v_0 := b.Controls[0]
-- if v_0.AuxInt != 0 {
-- break
-- }
-- l := v_0.Args[0]
-- if l.Op != OpARMMULA {
-- break
-- }
-- a := l.Args[2]
-- x := l.Args[0]
-- y := l.Args[1]
-- if !(l.Uses == 1) {
-- break
-- }
-- v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags)
-- v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type)
-- v1.AddArg2(x, y)
-- v0.AddArg2(a, v1)
-- b.resetWithControl(BlockARMGTnoov, v0)
-- return true
-- }
- // match: (GT (CMPconst [0] l:(ANDconst [c] x)) yes no)
- // cond: l.Uses==1
-- // result: (GT (TSTconst [c] x) yes no)
-+ // result: (GTnoov (TSTconst [c] x) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18204,12 +18204,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg(x)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- // match: (GT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (GT (TSTshiftLL x y [c]) yes no)
-+ // result: (GTnoov (TSTshiftLL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18228,12 +18228,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- // match: (GT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (GT (TSTshiftRL x y [c]) yes no)
-+ // result: (GTnoov (TSTshiftRL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18252,12 +18252,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- // match: (GT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (GT (TSTshiftRA x y [c]) yes no)
-+ // result: (GTnoov (TSTshiftRA x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18276,12 +18276,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- // match: (GT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (GT (TSTshiftLLreg x y z) yes no)
-+ // result: (GTnoov (TSTshiftLLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18299,12 +18299,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- // match: (GT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (GT (TSTshiftRLreg x y z) yes no)
-+ // result: (GTnoov (TSTshiftRLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18322,12 +18322,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- // match: (GT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (GT (TSTshiftRAreg x y z) yes no)
-+ // result: (GTnoov (TSTshiftRAreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18345,12 +18345,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- // match: (GT (CMPconst [0] l:(XOR x y)) yes no)
- // cond: l.Uses==1
-- // result: (GT (TEQ x y) yes no)
-+ // result: (GTnoov (TEQ x y) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18371,14 +18371,14 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags)
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- break
- }
- // match: (GT (CMPconst [0] l:(XORconst [c] x)) yes no)
- // cond: l.Uses==1
-- // result: (GT (TEQconst [c] x) yes no)
-+ // result: (GTnoov (TEQconst [c] x) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18396,12 +18396,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg(x)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- // match: (GT (CMPconst [0] l:(XORshiftLL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (GT (TEQshiftLL x y [c]) yes no)
-+ // result: (GTnoov (TEQshiftLL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18420,12 +18420,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- // match: (GT (CMPconst [0] l:(XORshiftRL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (GT (TEQshiftRL x y [c]) yes no)
-+ // result: (GTnoov (TEQshiftRL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18444,12 +18444,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- // match: (GT (CMPconst [0] l:(XORshiftRA x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (GT (TEQshiftRA x y [c]) yes no)
-+ // result: (GTnoov (TEQshiftRA x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18468,12 +18468,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- // match: (GT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (GT (TEQshiftLLreg x y z) yes no)
-+ // result: (GTnoov (TEQshiftLLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18491,12 +18491,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- // match: (GT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (GT (TEQshiftRLreg x y z) yes no)
-+ // result: (GTnoov (TEQshiftRLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18514,12 +18514,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- // match: (GT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (GT (TEQshiftRAreg x y z) yes no)
-+ // result: (GTnoov (TEQshiftRAreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -18537,7 +18537,7 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMGT, v0)
-+ b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
- case BlockARMGTnoov:
-@@ -19129,7 +19129,7 @@ func rewriteBlockARM(b *Block) bool {
- }
- // match: (LE (CMPconst [0] l:(AND x y)) yes no)
- // cond: l.Uses==1
-- // result: (LE (TST x y) yes no)
-+ // result: (LEnoov (TST x y) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19150,14 +19150,14 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags)
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- break
- }
- // match: (LE (CMPconst [0] l:(ANDconst [c] x)) yes no)
- // cond: l.Uses==1
-- // result: (LE (TSTconst [c] x) yes no)
-+ // result: (LEnoov (TSTconst [c] x) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19175,12 +19175,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg(x)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- // match: (LE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (LE (TSTshiftLL x y [c]) yes no)
-+ // result: (LEnoov (TSTshiftLL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19199,12 +19199,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- // match: (LE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (LE (TSTshiftRL x y [c]) yes no)
-+ // result: (LEnoov (TSTshiftRL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19223,12 +19223,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- // match: (LE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (LE (TSTshiftRA x y [c]) yes no)
-+ // result: (LEnoov (TSTshiftRA x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19247,12 +19247,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- // match: (LE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (LE (TSTshiftLLreg x y z) yes no)
-+ // result: (LEnoov (TSTshiftLLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19270,12 +19270,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- // match: (LE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (LE (TSTshiftRLreg x y z) yes no)
-+ // result: (LEnoov (TSTshiftRLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19293,12 +19293,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- // match: (LE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (LE (TSTshiftRAreg x y z) yes no)
-+ // result: (LEnoov (TSTshiftRAreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19316,12 +19316,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- // match: (LE (CMPconst [0] l:(XOR x y)) yes no)
- // cond: l.Uses==1
-- // result: (LE (TEQ x y) yes no)
-+ // result: (LEnoov (TEQ x y) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19342,14 +19342,14 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags)
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- break
- }
- // match: (LE (CMPconst [0] l:(XORconst [c] x)) yes no)
- // cond: l.Uses==1
-- // result: (LE (TEQconst [c] x) yes no)
-+ // result: (LEnoov (TEQconst [c] x) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19367,12 +19367,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg(x)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- // match: (LE (CMPconst [0] l:(XORshiftLL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (LE (TEQshiftLL x y [c]) yes no)
-+ // result: (LEnoov (TEQshiftLL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19391,12 +19391,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- // match: (LE (CMPconst [0] l:(XORshiftRL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (LE (TEQshiftRL x y [c]) yes no)
-+ // result: (LEnoov (TEQshiftRL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19415,12 +19415,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- // match: (LE (CMPconst [0] l:(XORshiftRA x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (LE (TEQshiftRA x y [c]) yes no)
-+ // result: (LEnoov (TEQshiftRA x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19439,12 +19439,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- // match: (LE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (LE (TEQshiftLLreg x y z) yes no)
-+ // result: (LEnoov (TEQshiftLLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19462,12 +19462,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- // match: (LE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (LE (TEQshiftRLreg x y z) yes no)
-+ // result: (LEnoov (TEQshiftRLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19485,12 +19485,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- // match: (LE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (LE (TEQshiftRAreg x y z) yes no)
-+ // result: (LEnoov (TEQshiftRAreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -19508,7 +19508,7 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMLE, v0)
-+ b.resetWithControl(BlockARMLEnoov, v0)
- return true
- }
- case BlockARMLEnoov:
-@@ -20009,7 +20009,7 @@ func rewriteBlockARM(b *Block) bool {
- }
- // match: (LT (CMPconst [0] l:(AND x y)) yes no)
- // cond: l.Uses==1
-- // result: (LT (TST x y) yes no)
-+ // result: (LTnoov (TST x y) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20030,14 +20030,14 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags)
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- break
- }
- // match: (LT (CMPconst [0] l:(ANDconst [c] x)) yes no)
- // cond: l.Uses==1
-- // result: (LT (TSTconst [c] x) yes no)
-+ // result: (LTnoov (TSTconst [c] x) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20055,12 +20055,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg(x)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- // match: (LT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (LT (TSTshiftLL x y [c]) yes no)
-+ // result: (LTnoov (TSTshiftLL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20079,12 +20079,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- // match: (LT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (LT (TSTshiftRL x y [c]) yes no)
-+ // result: (LTnoov (TSTshiftRL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20103,12 +20103,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- // match: (LT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (LT (TSTshiftRA x y [c]) yes no)
-+ // result: (LTnoov (TSTshiftRA x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20127,12 +20127,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- // match: (LT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (LT (TSTshiftLLreg x y z) yes no)
-+ // result: (LTnoov (TSTshiftLLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20150,12 +20150,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- // match: (LT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (LT (TSTshiftRLreg x y z) yes no)
-+ // result: (LTnoov (TSTshiftRLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20173,12 +20173,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- // match: (LT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (LT (TSTshiftRAreg x y z) yes no)
-+ // result: (LTnoov (TSTshiftRAreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20196,12 +20196,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- // match: (LT (CMPconst [0] l:(XOR x y)) yes no)
- // cond: l.Uses==1
-- // result: (LT (TEQ x y) yes no)
-+ // result: (LTnoov (TEQ x y) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20222,14 +20222,14 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags)
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- break
- }
- // match: (LT (CMPconst [0] l:(XORconst [c] x)) yes no)
- // cond: l.Uses==1
-- // result: (LT (TEQconst [c] x) yes no)
-+ // result: (LTnoov (TEQconst [c] x) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20247,12 +20247,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg(x)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- // match: (LT (CMPconst [0] l:(XORshiftLL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (LT (TEQshiftLL x y [c]) yes no)
-+ // result: (LTnoov (TEQshiftLL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20271,12 +20271,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- // match: (LT (CMPconst [0] l:(XORshiftRL x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (LT (TEQshiftRL x y [c]) yes no)
-+ // result: (LTnoov (TEQshiftRL x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20295,12 +20295,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- // match: (LT (CMPconst [0] l:(XORshiftRA x y [c])) yes no)
- // cond: l.Uses==1
-- // result: (LT (TEQshiftRA x y [c]) yes no)
-+ // result: (LTnoov (TEQshiftRA x y [c]) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20319,12 +20319,12 @@ func rewriteBlockARM(b *Block) bool {
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags)
- v0.AuxInt = c
- v0.AddArg2(x, y)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- // match: (LT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (LT (TEQshiftLLreg x y z) yes no)
-+ // result: (LTnoov (TEQshiftLLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20342,12 +20342,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- // match: (LT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (LT (TEQshiftRLreg x y z) yes no)
-+ // result: (LTnoov (TEQshiftRLreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20365,12 +20365,12 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- // match: (LT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no)
- // cond: l.Uses==1
-- // result: (LT (TEQshiftRAreg x y z) yes no)
-+ // result: (LTnoov (TEQshiftRAreg x y z) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
-@@ -20388,7 +20388,7 @@ func rewriteBlockARM(b *Block) bool {
- }
- v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags)
- v0.AddArg3(x, y, z)
-- b.resetWithControl(BlockARMLT, v0)
-+ b.resetWithControl(BlockARMLTnoov, v0)
- return true
- }
- case BlockARMLTnoov:
-diff --git a/test/fixedbugs/issue42876.go b/test/fixedbugs/issue42876.go
-new file mode 100644
-index 0000000000..67cf4919ac
---- /dev/null
-+++ b/test/fixedbugs/issue42876.go
-@@ -0,0 +1,18 @@
-+// run
-+
-+// Copyright 2020 The Go Authors. All rights reserved.
-+// Use of this source code is governed by a BSD-style
-+// license that can be found in the LICENSE file.
-+
-+package main
-+
-+var x = [4]int32{-0x7fffffff, 0x7fffffff, 2, 4}
-+
-+func main() {
-+ if x[0] > x[1] {
-+ panic("fail 1")
-+ }
-+ if x[2]&x[3] < 0 {
-+ panic("fail 2") // Fails here
-+ }
-+}
---
-2.27.0
-
diff --git a/0073-release-branch.go1.17-crypto-rand-properly-handle-la.patch b/0015-release-branch.go1.17-crypto-rand-properly-handle-la.patch
similarity index 72%
rename from 0073-release-branch.go1.17-crypto-rand-properly-handle-la.patch
rename to 0015-release-branch.go1.17-crypto-rand-properly-handle-la.patch
index cb1d4509dd5fec1367b60bd997f671a9a4ebf329..092814022de625d9ed3205ff3821ec33ae0f0350 100644
--- a/0073-release-branch.go1.17-crypto-rand-properly-handle-la.patch
+++ b/0015-release-branch.go1.17-crypto-rand-properly-handle-la.patch
@@ -1,7 +1,7 @@
-From 4dfd37e5c41d531b9e5eb9618a0683d67ef3e594 Mon Sep 17 00:00:00 2001
+From 07a30769186210c1b1e25943824743355c4e50f5 Mon Sep 17 00:00:00 2001
From: Roland Shoemaker
Date: Mon, 25 Apr 2022 19:02:35 -0700
-Subject: [PATCH 10/10] [release-branch.go1.17] crypto/rand: properly handle
+Subject: [PATCH 11/11] [release-branch.go1.17] crypto/rand: properly handle
large Read on windows
Use the batched reader to chunk large Read calls on windows to a max of
@@ -25,23 +25,24 @@ TryBot-Result: Gopher Robot
Reviewed-on: https://go-review.googlesource.com/c/go/+/406635
Reviewed-by: Damien Neil
-Conflict: src/crypto/rand/rand.go, src/crypto/rand/rand_windows.go
+Conflict: NA
Reference: https://go-review.googlesource.com/c/go/+/406635
---
- src/crypto/rand/rand.go | 18 +++++++++++++++
- src/crypto/rand/rand_batched.go | 22 +++++--------------
- src/crypto/rand/rand_batched_test.go | 21 +++++++++---------
+ src/crypto/rand/rand.go | 18 ++++++++++++++++++
+ src/crypto/rand/rand_batched.go | 22 ++++++----------------
+ src/crypto/rand/rand_batched_test.go | 21 +++++++++++----------
+ src/crypto/rand/rand_getentropy.go | 6 +++---
src/crypto/rand/rand_unix.go | 4 ++--
- src/crypto/rand/rand_windows.go | 33 +++++-----------------------
- 5 files changed, 43 insertions(+), 55 deletions(-)
+ src/crypto/rand/rand_windows.go | 18 ++++++------------
+ 6 files changed, 46 insertions(+), 43 deletions(-)
diff --git a/src/crypto/rand/rand.go b/src/crypto/rand/rand.go
-index a5ccd19de32..5606f248f02 100644
+index fddd1147e6e..f2c276008d7 100644
--- a/src/crypto/rand/rand.go
+++ b/src/crypto/rand/rand.go
-@@ -27,3 +27,21 @@ func Read(b []byte) (n int, err error) {
- func warnBlocked() {
- println("crypto/rand: blocked for 60 seconds waiting to read random data from the kernel")
+@@ -23,3 +23,21 @@ var Reader io.Reader
+ func Read(b []byte) (n int, err error) {
+ return io.ReadFull(Reader, b)
}
+
+// batched returns a function that calls f to populate a []byte by chunking it
@@ -62,10 +63,10 @@ index a5ccd19de32..5606f248f02 100644
+ }
+}
diff --git a/src/crypto/rand/rand_batched.go b/src/crypto/rand/rand_batched.go
-index 60267fd4bc2..cad958d79c0 100644
+index d7c5bf3562d..8df715fdd14 100644
--- a/src/crypto/rand/rand_batched.go
+++ b/src/crypto/rand/rand_batched.go
-@@ -7,6 +7,7 @@
+@@ -8,6 +8,7 @@
package rand
import (
@@ -73,7 +74,7 @@ index 60267fd4bc2..cad958d79c0 100644
"internal/syscall/unix"
)
-@@ -15,20 +16,6 @@ func init() {
+@@ -16,20 +17,6 @@ func init() {
altGetRandom = batched(getRandomBatch, maxGetRandomRead)
}
@@ -94,7 +95,7 @@ index 60267fd4bc2..cad958d79c0 100644
// If the kernel is too old to support the getrandom syscall(),
// unix.GetRandom will immediately return ENOSYS and we will then fall back to
// reading from /dev/urandom in rand_unix.go. unix.GetRandom caches the ENOSYS
-@@ -36,7 +23,10 @@ func batched(f func([]byte) bool, readMax int) func([]byte) bool {
+@@ -37,7 +24,10 @@ func batched(f func([]byte) bool, readMax int) func([]byte) bool {
// If the kernel supports the getrandom() syscall, unix.GetRandom will block
// until the kernel has sufficient randomness (as we don't use GRND_NONBLOCK).
// In this case, unix.GetRandom will not return an error.
@@ -108,10 +109,10 @@ index 60267fd4bc2..cad958d79c0 100644
+ return err
}
diff --git a/src/crypto/rand/rand_batched_test.go b/src/crypto/rand/rand_batched_test.go
-index 837db83f770..8122bceba4b 100644
+index 2d20922c825..b56345e50f1 100644
--- a/src/crypto/rand/rand_batched_test.go
+++ b/src/crypto/rand/rand_batched_test.go
-@@ -8,20 +8,21 @@ package rand
+@@ -9,20 +9,21 @@ package rand
import (
"bytes"
@@ -137,7 +138,7 @@ index 837db83f770..8122bceba4b 100644
}
expected := []byte{0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2}
if !bytes.Equal(expected, p) {
-@@ -30,15 +31,15 @@ func TestBatched(t *testing.T) {
+@@ -31,15 +32,15 @@ func TestBatched(t *testing.T) {
}
func TestBatchedError(t *testing.T) {
@@ -159,20 +160,44 @@ index 837db83f770..8122bceba4b 100644
+ t.Fatalf("empty slice should always return nil: %s", err)
}
}
+diff --git a/src/crypto/rand/rand_getentropy.go b/src/crypto/rand/rand_getentropy.go
+index dd725372ad9..b1c19f3d0da 100644
+--- a/src/crypto/rand/rand_getentropy.go
++++ b/src/crypto/rand/rand_getentropy.go
+@@ -15,7 +15,7 @@ func init() {
+ altGetRandom = getEntropy
+ }
+
+-func getEntropy(p []byte) (ok bool) {
++func getEntropy(p []byte) error {
+ // getentropy(2) returns a maximum of 256 bytes per call
+ for i := 0; i < len(p); i += 256 {
+ end := i + 256
+@@ -24,8 +24,8 @@ func getEntropy(p []byte) (ok bool) {
+ }
+ err := unix.GetEntropy(p[i:end])
+ if err != nil {
+- return false
++ return err
+ }
+ }
+- return true
++ return nil
+ }
diff --git a/src/crypto/rand/rand_unix.go b/src/crypto/rand/rand_unix.go
-index 0610f691b0d..5ddc76be266 100644
+index 81277eb6a5d..3d11159a340 100644
--- a/src/crypto/rand/rand_unix.go
+++ b/src/crypto/rand/rand_unix.go
-@@ -45,7 +45,7 @@ type devReader struct {
+@@ -46,7 +46,7 @@ type devReader struct {
// altGetRandom if non-nil specifies an OS-specific function to get
// urandom-style randomness.
-var altGetRandom func([]byte) (ok bool)
+var altGetRandom func([]byte) (err error)
- func (r *devReader) Read(b []byte) (n int, err error) {
- if atomic.CompareAndSwapInt32(&r.used, 0, 1) {
-@@ -54,7 +54,7 @@ func (r *devReader) Read(b []byte) (n int, err error) {
+ func warnBlocked() {
+ println("crypto/rand: blocked for 60 seconds waiting to read random data from the kernel")
+@@ -59,7 +59,7 @@ func (r *devReader) Read(b []byte) (n int, err error) {
t := time.AfterFunc(60*time.Second, warnBlocked)
defer t.Stop()
}
@@ -182,57 +207,39 @@ index 0610f691b0d..5ddc76be266 100644
}
r.mu.Lock()
diff --git a/src/crypto/rand/rand_windows.go b/src/crypto/rand/rand_windows.go
-index 78a4ed6d67b..b5036ba9713 100644
+index 7379f1489ad..6c0655c72b6 100644
--- a/src/crypto/rand/rand_windows.go
+++ b/src/crypto/rand/rand_windows.go
-@@ -8,11 +8,9 @@
- package rand
+@@ -9,7 +9,6 @@ package rand
import (
+ "internal/syscall/windows"
- "os"
-+ "internal/syscall/windows"
- "sync"
-- "sync/atomic"
- "syscall"
-- "time"
)
- // Implemented by using Windows CryptoAPI 2.0.
-@@ -27,30 +25,11 @@ type rngReader struct {
- }
+ func init() { Reader = &rngReader{} }
+@@ -17,16 +16,11 @@ func init() { Reader = &rngReader{} }
+ type rngReader struct{}
func (r *rngReader) Read(b []byte) (n int, err error) {
-- if atomic.CompareAndSwapInt32(&r.used, 0, 1) {
-- // First use of randomness. Start timer to warn about
-- // being blocked on entropy not being available.
-- t := time.AfterFunc(60*time.Second, warnBlocked)
-- defer t.Stop()
-- }
-- r.mu.Lock()
-- if r.prov == 0 {
-- const provType = syscall.PROV_RSA_FULL
-- const flags = syscall.CRYPT_VERIFYCONTEXT | syscall.CRYPT_SILENT
-- err := syscall.CryptAcquireContext(&r.prov, nil, nil, provType, flags)
-- if err != nil {
-- r.mu.Unlock()
-- return 0, os.NewSyscallError("CryptAcquireContext", err)
-- }
-- }
-- r.mu.Unlock()
+- // RtlGenRandom only accepts 2**32-1 bytes at a time, so truncate.
+- inputLen := uint32(len(b))
-
-- if len(b) == 0 {
+- if inputLen == 0 {
- return 0, nil
- }
-- err = syscall.CryptGenRandom(r.prov, uint32(len(b)), &b[0])
+-
+- err = windows.RtlGenRandom(b)
- if err != nil {
-- return 0, os.NewSyscallError("CryptGenRandom", err)
+- return 0, os.NewSyscallError("RtlGenRandom", err)
+ // RtlGenRandom only returns 1<<32-1 bytes at a time. We only read at
+ // most 1<<31-1 bytes at a time so that this works the same on 32-bit
+ // and 64-bit systems.
+ if err := batched(windows.RtlGenRandom, 1<<31-1)(b); err != nil {
+ return 0, err
}
- return len(b), nil
+- return int(inputLen), nil
++ return len(b), nil
}
--
2.30.2
diff --git a/0016-release-branch.go1.15-syscall-do-not-overflow-key-me.patch b/0016-release-branch.go1.15-syscall-do-not-overflow-key-me.patch
deleted file mode 100644
index 08f29f32a988eea5b3a81fb28ab12b584fd86ff6..0000000000000000000000000000000000000000
--- a/0016-release-branch.go1.15-syscall-do-not-overflow-key-me.patch
+++ /dev/null
@@ -1,115 +0,0 @@
-From 4fda89d4201fc9f0c1e192bbcc95dd8d660e9122 Mon Sep 17 00:00:00 2001
-From: "Jason A. Donenfeld"
-Date: Tue, 23 Feb 2021 13:29:40 +0100
-Subject: [PATCH 16/44] [release-branch.go1.15] syscall: do not overflow key
- memory in GetQueuedCompletionStatus
-
-The third argument to GetQueuedCompletionStatus is a pointer to a
-uintptr, not a uint32. Users of this functions have therefore been
-corrupting their memory every time they used it. Either that memory
-corruption was silent (dangerous), or their programs didn't work so they
-chose a different API to use.
-
-This fixes the problem by passing through an intermediate buffer.
-
-Updates #44538.
-Fixes #44592.
-
-Change-Id: Icacd71f705b36e41e52bd8c4d74898559a27522f
-Reviewed-on: https://go-review.googlesource.com/c/go/+/296151
-Trust: Jason A. Donenfeld
-Run-TryBot: Jason A. Donenfeld
-TryBot-Result: Go Bot
-Reviewed-by: Bryan C. Mills
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/4fda89d4201fc9f0c1e192bbcc95dd8d660e9122
-
----
- src/syscall/syscall_windows.go | 34 ++++++++++++++++++++++++++++++---
- src/syscall/zsyscall_windows.go | 6 +++---
- 2 files changed, 34 insertions(+), 6 deletions(-)
-
-diff --git a/src/syscall/syscall_windows.go b/src/syscall/syscall_windows.go
-index f62c00d72f..fbb11a89ca 100644
---- a/src/syscall/syscall_windows.go
-+++ b/src/syscall/syscall_windows.go
-@@ -213,9 +213,9 @@ func NewCallbackCDecl(fn interface{}) uintptr {
- //sys SetEndOfFile(handle Handle) (err error)
- //sys GetSystemTimeAsFileTime(time *Filetime)
- //sys GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) [failretval==0xffffffff]
--//sys CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error)
--//sys GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error)
--//sys PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error)
-+//sys createIoCompletionPort(filehandle Handle, cphandle Handle, key uintptr, threadcnt uint32) (handle Handle, err error) = CreateIoCompletionPort
-+//sys getQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uintptr, overlapped **Overlapped, timeout uint32) (err error) = GetQueuedCompletionStatus
-+//sys postQueuedCompletionStatus(cphandle Handle, qty uint32, key uintptr, overlapped *Overlapped) (err error) = PostQueuedCompletionStatus
- //sys CancelIo(s Handle) (err error)
- //sys CancelIoEx(s Handle, o *Overlapped) (err error)
- //sys CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) = CreateProcessW
-@@ -1209,3 +1209,31 @@ func Readlink(path string, buf []byte) (n int, err error) {
-
- return n, nil
- }
-+
-+// Deprecated: CreateIoCompletionPort has the wrong function signature. Use x/sys/windows.CreateIoCompletionPort.
-+func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (Handle, error) {
-+ return createIoCompletionPort(filehandle, cphandle, uintptr(key), threadcnt)
-+}
-+
-+// Deprecated: GetQueuedCompletionStatus has the wrong function signature. Use x/sys/windows.GetQueuedCompletionStatus.
-+func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) error {
-+ var ukey uintptr
-+ var pukey *uintptr
-+ if key != nil {
-+ ukey = uintptr(*key)
-+ pukey = &ukey
-+ }
-+ err := getQueuedCompletionStatus(cphandle, qty, pukey, overlapped, timeout)
-+ if key != nil {
-+ *key = uint32(ukey)
-+ if uintptr(*key) != ukey && err == nil {
-+ err = errorspkg.New("GetQueuedCompletionStatus returned key overflow")
-+ }
-+ }
-+ return err
-+}
-+
-+// Deprecated: PostQueuedCompletionStatus has the wrong function signature. Use x/sys/windows.PostQueuedCompletionStatus.
-+func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) error {
-+ return postQueuedCompletionStatus(cphandle, qty, uintptr(key), overlapped)
-+}
-diff --git a/src/syscall/zsyscall_windows.go b/src/syscall/zsyscall_windows.go
-index 2348f6534f..2762fb3b74 100644
---- a/src/syscall/zsyscall_windows.go
-+++ b/src/syscall/zsyscall_windows.go
-@@ -539,7 +539,7 @@ func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) {
- return
- }
-
--func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) {
-+func createIoCompletionPort(filehandle Handle, cphandle Handle, key uintptr, threadcnt uint32) (handle Handle, err error) {
- r0, _, e1 := Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0)
- handle = Handle(r0)
- if handle == 0 {
-@@ -552,7 +552,7 @@ func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, thre
- return
- }
-
--func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) {
-+func getQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uintptr, overlapped **Overlapped, timeout uint32) (err error) {
- r1, _, e1 := Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
- if r1 == 0 {
- if e1 != 0 {
-@@ -564,7 +564,7 @@ func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overla
- return
- }
-
--func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) {
-+func postQueuedCompletionStatus(cphandle Handle, qty uint32, key uintptr, overlapped *Overlapped) (err error) {
- r1, _, e1 := Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
---
-2.27.0
-
diff --git a/0074-release-branch.go1.17-math-big-check-buffer-lengths-.patch b/0016-release-branch.go1.17-math-big-check-buffer-lengths-.patch
similarity index 96%
rename from 0074-release-branch.go1.17-math-big-check-buffer-lengths-.patch
rename to 0016-release-branch.go1.17-math-big-check-buffer-lengths-.patch
index abaa9a1784bbe314aa2f42da4c2ebc97d43be212..78f8090c522ff73f635f567a3ce02cd46d419180 100644
--- a/0074-release-branch.go1.17-math-big-check-buffer-lengths-.patch
+++ b/0016-release-branch.go1.17-math-big-check-buffer-lengths-.patch
@@ -1,4 +1,4 @@
-From 490df635ab990bcc5796cf5765c74675503d9964 Mon Sep 17 00:00:00 2001
+From dc903a8196a831d23e9b6504239e09a9e6bcd98a Mon Sep 17 00:00:00 2001
From: Roland Shoemaker
Date: Fri, 15 Jul 2022 10:43:44 -0700
Subject: [PATCH] [release-branch.go1.17] math/big: check buffer lengths in
@@ -18,10 +18,6 @@ Run-TryBot: Roland Shoemaker
(cherry picked from commit 055113ef364337607e3e72ed7d48df67fde6fc66)
Reviewed-on: https://go-review.googlesource.com/c/go/+/419814
Reviewed-by: Julie Qiu
-
-Conflict:NA
-Reference:https://go-review.googlesource.com/c/go/+/419814
-
---
src/math/big/floatmarsh.go | 7 +++++++
src/math/big/floatmarsh_test.go | 12 ++++++++++++
diff --git a/0075-path-filepath-do-not-remove-prefix-.-when-following-.patch b/0017-path-filepath-do-not-remove-prefix-.-when-following-.patch
similarity index 88%
rename from 0075-path-filepath-do-not-remove-prefix-.-when-following-.patch
rename to 0017-path-filepath-do-not-remove-prefix-.-when-following-.patch
index 96de818716967e414b446b76db640b06bae413e0..0f44f3850d75025e402eebca56b103c2e0751d04 100644
--- a/0075-path-filepath-do-not-remove-prefix-.-when-following-.patch
+++ b/0017-path-filepath-do-not-remove-prefix-.-when-following-.patch
@@ -1,4 +1,4 @@
-From 0de49f05ec2b03819ae698c97e9445a6ab928d4c Mon Sep 17 00:00:00 2001
+From e903e474f9632a151fff2df3dd3e891395f1a8f1 Mon Sep 17 00:00:00 2001
From: Yasuhiro Matsumoto
Date: Fri, 22 Apr 2022 10:07:51 +0900
Subject: [PATCH 1/2] path/filepath: do not remove prefix "." when following
@@ -15,9 +15,8 @@ Reviewed-by: Ian Lance Taylor
Reviewed-by: Damien Neil
TryBot-Result: Gopher Robot
-Conflict: NA
-Reference: https://go-review.googlesource.com/c/go/+/401595/
-
+Reference:https://go-review.googlesource.com/c/go/+/401595/
+Conflict:NA
---
src/path/filepath/path.go | 14 +++++++++++++-
src/path/filepath/path_test.go | 3 +++
@@ -25,10 +24,10 @@ Reference: https://go-review.googlesource.com/c/go/+/401595/
3 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/src/path/filepath/path.go b/src/path/filepath/path.go
-index 26f1833189..92dc090eea 100644
+index b56534dead..8300a32cb1 100644
--- a/src/path/filepath/path.go
+++ b/src/path/filepath/path.go
-@@ -116,9 +116,21 @@ func Clean(path string) string {
+@@ -117,9 +117,21 @@ func Clean(path string) string {
case os.IsPathSeparator(path[r]):
// empty path element
r++
@@ -52,7 +51,7 @@ index 26f1833189..92dc090eea 100644
// .. element: remove to last separator
r += 2
diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go
-index d6f680556c..531a66333b 100644
+index bc5509b49c..ed17a8854d 100644
--- a/src/path/filepath/path_test.go
+++ b/src/path/filepath/path_test.go
@@ -93,6 +93,9 @@ var wincleantests = []PathTest{
@@ -66,10 +65,10 @@ index d6f680556c..531a66333b 100644
func TestClean(t *testing.T) {
diff --git a/src/path/filepath/path_windows_test.go b/src/path/filepath/path_windows_test.go
-index f7c454bf65..e3979fe1e7 100644
+index 76a459ac96..3edafb5a85 100644
--- a/src/path/filepath/path_windows_test.go
+++ b/src/path/filepath/path_windows_test.go
-@@ -581,3 +581,29 @@ func TestNTNamespaceSymlink(t *testing.T) {
+@@ -530,3 +530,29 @@ func TestNTNamespaceSymlink(t *testing.T) {
t.Errorf(`EvalSymlinks(%q): got %q, want %q`, filelink, got, want)
}
}
diff --git a/0017-release-branch.go1.15-time-correct-unusual-extension.patch b/0017-release-branch.go1.15-time-correct-unusual-extension.patch
deleted file mode 100644
index 9c58dc79a18b3edb587511e2e49335aa607f4c8e..0000000000000000000000000000000000000000
--- a/0017-release-branch.go1.15-time-correct-unusual-extension.patch
+++ /dev/null
@@ -1,150 +0,0 @@
-From 6bb96000b3215a84d0a5193e387cf809d2fa2800 Mon Sep 17 00:00:00 2001
-From: Ian Lance Taylor
-Date: Thu, 25 Feb 2021 10:01:56 -0800
-Subject: [PATCH 17/44] [release-branch.go1.15] time: correct unusual extension
- string cases
-
-This fixes two uncommon cases.
-
-First, the tzdata code permits timezone offsets up to 24 * 7, although
-the POSIX TZ parsing does not. The tzdata code uses this to specify a
-day of week in some cases.
-
-Second, we incorrectly rejected a negative time offset for when a time
-zone change comes into effect.
-
-For #44385
-Fixes #44617
-
-Change-Id: I5f2efc1d385e9bfa974a0de3fa81e7a94b827602
-Reviewed-on: https://go-review.googlesource.com/c/go/+/296392
-Trust: Ian Lance Taylor
-Run-TryBot: Ian Lance Taylor
-TryBot-Result: Go Bot
-Reviewed-by: Tobias Klauser
-(cherry picked from commit d9fd38e68ba00a51c2c7363150688d0e7687ef84)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/297229
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/6bb96000b3215a84d0a5193e387cf809d2fa2800
-
----
- src/time/zoneinfo.go | 6 ++--
- src/time/zoneinfo_test.go | 60 +++++++++++++++++++++++++++++----------
- 2 files changed, 49 insertions(+), 17 deletions(-)
-
-diff --git a/src/time/zoneinfo.go b/src/time/zoneinfo.go
-index c3662297c7..6db9443474 100644
---- a/src/time/zoneinfo.go
-+++ b/src/time/zoneinfo.go
-@@ -377,8 +377,10 @@ func tzsetOffset(s string) (offset int, rest string, ok bool) {
- neg = true
- }
-
-+ // The tzdata code permits values up to 24 * 7 here,
-+ // although POSIX does not.
- var hours int
-- hours, s, ok = tzsetNum(s, 0, 24)
-+ hours, s, ok = tzsetNum(s, 0, 24*7)
- if !ok {
- return 0, "", false
- }
-@@ -487,7 +489,7 @@ func tzsetRule(s string) (rule, string, bool) {
- }
-
- offset, s, ok := tzsetOffset(s[1:])
-- if !ok || offset < 0 {
-+ if !ok {
- return rule{}, "", false
- }
- r.time = offset
-diff --git a/src/time/zoneinfo_test.go b/src/time/zoneinfo_test.go
-index 277b68f798..d043e1e9f1 100644
---- a/src/time/zoneinfo_test.go
-+++ b/src/time/zoneinfo_test.go
-@@ -183,22 +183,50 @@ func TestMalformedTZData(t *testing.T) {
- }
- }
-
--func TestLoadLocationFromTZDataSlim(t *testing.T) {
-- // A 2020b slim tzdata for Europe/Berlin
-- tzData := "TZif2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00TZif2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00<\x00\x00\x00\x04\x00\x00\x00\x12\xff\xff\xff\xffo\xa2a\xf8\xff\xff\xff\xff\x9b\f\x17`\xff\xff\xff\xff\x9b\xd5\xda\xf0\xff\xff\xff\xff\x9cٮ\x90\xff\xff\xff\xff\x9d\xa4\xb5\x90\xff\xff\xff\xff\x9e\xb9\x90\x90\xff\xff\xff\xff\x9f\x84\x97\x90\xff\xff\xff\xff\xc8\tq\x90\xff\xff\xff\xff\xcc\xe7K\x10\xff\xff\xff\xffͩ\x17\x90\xff\xff\xff\xff\u03a2C\x10\xff\xff\xff\xffϒ4\x10\xff\xff\xff\xffЂ%\x10\xff\xff\xff\xff\xd1r\x16\x10\xff\xff\xff\xffѶ\x96\x00\xff\xff\xff\xff\xd2X\xbe\x80\xff\xff\xff\xffҡO\x10\xff\xff\xff\xff\xd3c\x1b\x90\xff\xff\xff\xff\xd4K#\x90\xff\xff\xff\xff\xd59\xd1 \xff\xff\xff\xff\xd5g\xe7\x90\xff\xff\xff\xffըs\x00\xff\xff\xff\xff\xd6)\xb4\x10\xff\xff\xff\xff\xd7,\x1a\x10\xff\xff\xff\xff\xd8\t\x96\x10\xff\xff\xff\xff\xd9\x02\xc1\x90\xff\xff\xff\xff\xd9\xe9x\x10\x00\x00\x00\x00\x13MD\x10\x00\x00\x00\x00\x143\xfa\x90\x00\x00\x00\x00\x15#\xeb\x90\x00\x00\x00\x00\x16\x13ܐ\x00\x00\x00\x00\x17\x03͐\x00\x00\x00\x00\x17\xf3\xbe\x90\x00\x00\x00\x00\x18㯐\x00\x00\x00\x00\x19Ӡ\x90\x00\x00\x00\x00\x1aÑ\x90\x00\x00\x00\x00\x1b\xbc\xbd\x10\x00\x00\x00\x00\x1c\xac\xae\x10\x00\x00\x00\x00\x1d\x9c\x9f\x10\x00\x00\x00\x00\x1e\x8c\x90\x10\x00\x00\x00\x00\x1f|\x81\x10\x00\x00\x00\x00 lr\x10\x00\x00\x00\x00!\\c\x10\x00\x00\x00\x00\"LT\x10\x00\x00\x00\x00#3<-02>,M3.5.0/-2,M10.5.0/-1\n",
-+ wantName: "-03",
-+ wantOffset: -10800,
-+ },
-+ {
-+ // 2021a slim tzdata for Asia/Gaza.
-+ zoneName: "Asia/Gaza",
-+ tzData: "TZif3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00TZif3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00s\x00\x00\x00\x05\x00\x00\x00\x15\xff\xff\xff\xff}\xbdJ\xb0\xff\xff\xff\xff\xc8Y\xcf\x00\xff\xff\xff\xff\xc8\xfa\xa6\x00\xff\xff\xff\xff\xc98\x9c\x80\xff\xff\xff\xff\xcc\xe5\xeb\x80\xff\xff\xff\xffͬ\xfe\x00\xff\xff\xff\xff\xce\xc7\x1f\x00\xff\xff\xff\xffϏ\x83\x00\xff\xff\xff\xffЩ\xa4\x00\xff\xff\xff\xffф}\x00\xff\xff\xff\xffҊ׀\xff\xff\xff\xff\xd3e\xb0\x80\xff\xff\xff\xff\xd4l\v\x00\xff\xff\xff\xff\xe86c`\xff\xff\xff\xff\xe8\xf4-P\xff\xff\xff\xff\xea\v\xb9`\xff\xff\xff\xff\xea\xd5`\xd0\xff\xff\xff\xff\xeb\xec\xfa\xf0\xff\xff\xff\xff\xec\xb5m\x00\xff\xff\xff\xff\xed\xcf\u007f\xf0\xff\xff\xff\xff\xee\x97\xf2\x00\xff\xff\xff\xffﰳp\xff\xff\xff\xff\xf0y%\x80\xff\xff\xff\xff\xf1\x91\xe6\xf0\xff\xff\xff\xff\xf2ZY\x00\xff\xff\xff\xff\xf3s\x1ap\xff\xff\xff\xff\xf4;\x8c\x80\xff\xff\xff\xff\xf5U\x9fp\xff\xff\xff\xff\xf6\x1e\x11\x80\xff\xff\xff\xff\xf76\xd2\xf0\xff\xff\xff\xff\xf7\xffE\x00\xff\xff\xff\xff\xf9\x18\x06p\xff\xff\xff\xff\xf9\xe1\xca\x00\xff\xff\xff\xff\xfa\xf99\xf0\xff\xff\xff\xff\xfb'BP\x00\x00\x00\x00\b|\x8b\xe0\x00\x00\x00\x00\b\xfd\xb0\xd0\x00\x00\x00\x00\t\xf6\xea`\x00\x00\x00\x00\n\xa63\xd0\x00\x00\x00\x00\x13\xe9\xfc`\x00\x00\x00\x00\x14![`\x00\x00\x00\x00\x1a\xfa\xc6`\x00\x00\x00\x00\x1b\x8en`\x00\x00\x00\x00\x1c\xbe\xf8\xe0\x00\x00\x00\x00\x1dw|\xd0\x00\x00\x00\x00\x1e\xcc\xff`\x00\x00\x00\x00\x1f`\x99P\x00\x00\x00\x00 \x82\xb1`\x00\x00\x00\x00!I\xb5\xd0\x00\x00\x00\x00\"^\x9e\xe0\x00\x00\x00\x00# ]P\x00\x00\x00\x00$Z0`\x00\x00\x00\x00%\x00?P\x00\x00\x00\x00&\v\xed\xe0\x00\x00\x00\x00&\xd6\xe6\xd0\x00\x00\x00\x00'\xeb\xcf\xe0\x00\x00\x00\x00(\xc0\x03P\x00\x00\x00\x00)\xd4\xec`\x00\x00\x00\x00*\xa9\x1f\xd0\x00\x00\x00\x00+\xbbe\xe0\x00\x00\x00\x00,\x89\x01\xd0\x00\x00\x00\x00-\x9bG\xe0\x00\x00\x00\x00._\xa9P\x00\x00\x00\x00/{)\xe0\x00\x00\x00\x000H\xc5\xd0\x00\x00\x00\x000\xe7\a\xe0\x00\x00\x00\x001dF`\x00\x00\x00\x002A\xc2`\x00\x00\x00\x003D(`\x00\x00\x00\x004!\xa4`\x00\x00\x00\x005$\n`\x00\x00\x00\x006\x01\x86`\x00\x00\x00\x007\x16a`\x00\x00\x00\x008\x06DP\x00\x00\x00\x008\xff}\xe0\x00\x00\x00\x009\xef`\xd0\x00\x00\x00\x00:\xdf_\xe0\x00\x00\x00\x00;\xcfB\xd0\x00\x00\x00\x00<\xbfA\xe0\x00\x00\x00\x00=\xaf$\xd0\x00\x00\x00\x00>\x9f#\xe0\x00\x00\x00\x00?\x8f\x06\xd0\x00\x00\x00\x00@\u007f\x05\xe0\x00\x00\x00\x00A\\\x81\xe0\x00\x00\x00\x00B^\xe7\xe0\x00\x00\x00\x00CA\xb7\xf0\x00\x00\x00\x00D-\xa6`\x00\x00\x00\x00E\x12\xfdP\x00\x00\x00\x00F\x0e\xd9\xe0\x00\x00\x00\x00F\xe8op\x00\x00\x00\x00G\xec\x18\xe0\x00\x00\x00\x00H\xb7\x11\xd0\x00\x00\x00\x00I\xcb\xfa\xe0\x00\x00\x00\x00J\xa0<`\x00\x00\x00\x00K\xad.\x9c\x00\x00\x00\x00La\xbd\xd0\x00\x00\x00\x00M\x94\xf9\x9c\x00\x00\x00\x00N5\xc2P\x00\x00\x00\x00Ot\xdb`\x00\x00\x00\x00P[\x91\xe0\x00\x00\x00\x00QT\xbd`\x00\x00\x00\x00RD\xa0P\x00\x00\x00\x00S4\x9f`\x00\x00\x00\x00TIlP\x00\x00\x00\x00U\x15\xd2\xe0\x00\x00\x00\x00V)\\`\x00\x00\x00\x00V\xf5\xc2\xf0\x00\x00\x00\x00X\x13\xca`\x00\x00\x00\x00Xդ\xf0\x00\x00\x00\x00Y\xf3\xac`\x00\x00\x00\x00Z\xb5\x86\xf0\x00\x00\x00\x00[ӎ`\x00\x00\x00\x00\\\x9dC\xe0\x00\x00\x00\x00]\xb3bP\x00\x00\x00\x00^~w`\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x00\x00 P\x00\x00\x00\x00*0\x01\x04\x00\x00\x1c \x00\t\x00\x00*0\x01\r\x00\x00\x1c \x00\x11LMT\x00EEST\x00EET\x00IDT\x00IST\x00\nEET-2EEST,M3.4.4/48,M10.4.4/49\n",
-+ wantName: "EET",
-+ wantOffset: 7200,
-+ },
-+}
-
-- reference, err := time.LoadLocationFromTZData("Europe/Berlin", []byte(tzData))
-- if err != nil {
-- t.Fatal(err)
-- }
-+func TestLoadLocationFromTZDataSlim(t *testing.T) {
-+ for _, test := range slimTests {
-+ reference, err := time.LoadLocationFromTZData(test.zoneName, []byte(test.tzData))
-+ if err != nil {
-+ t.Fatal(err)
-+ }
-
-- d := time.Date(2020, time.October, 29, 15, 30, 0, 0, reference)
-- tzName, tzOffset := d.Zone()
-- if want := "CET"; tzName != want {
-- t.Errorf("Zone name == %s, want %s", tzName, want)
-- }
-- if want := 3600; tzOffset != want {
-- t.Errorf("Zone offset == %d, want %d", tzOffset, want)
-+ d := time.Date(2020, time.October, 29, 15, 30, 0, 0, reference)
-+ tzName, tzOffset := d.Zone()
-+ if tzName != test.wantName {
-+ t.Errorf("Zone name == %s, want %s", tzName, test.wantName)
-+ }
-+ if tzOffset != test.wantOffset {
-+ t.Errorf("Zone offset == %d, want %d", tzOffset, test.wantOffset)
-+ }
- }
- }
-
-@@ -263,7 +291,8 @@ func TestTzsetOffset(t *testing.T) {
- {"+08", 8 * 60 * 60, "", true},
- {"-01:02:03", -1*60*60 - 2*60 - 3, "", true},
- {"01", 1 * 60 * 60, "", true},
-- {"100", 0, "", false},
-+ {"100", 100 * 60 * 60, "", true},
-+ {"1000", 0, "", false},
- {"8PDT", 8 * 60 * 60, "PDT", true},
- } {
- off, out, ok := time.TzsetOffset(test.in)
-@@ -288,6 +317,7 @@ func TestTzsetRule(t *testing.T) {
- {"30/03:00:00", time.Rule{Kind: time.RuleDOY, Day: 30, Time: 3 * 60 * 60}, "", true},
- {"M4.5.6/03:00:00", time.Rule{Kind: time.RuleMonthWeekDay, Mon: 4, Week: 5, Day: 6, Time: 3 * 60 * 60}, "", true},
- {"M4.5.7/03:00:00", time.Rule{}, "", false},
-+ {"M4.5.6/-04", time.Rule{Kind: time.RuleMonthWeekDay, Mon: 4, Week: 5, Day: 6, Time: -4 * 60 * 60}, "", true},
- } {
- r, out, ok := time.TzsetRule(test.in)
- if r != test.r || out != test.out || ok != test.ok {
---
-2.27.0
-
diff --git a/0018-release-branch.go1.15-cmd-compile-fix-escape-analysi.patch b/0018-release-branch.go1.15-cmd-compile-fix-escape-analysi.patch
deleted file mode 100644
index e13076f4d3921c04fb65f93955890b66b4eb2455..0000000000000000000000000000000000000000
--- a/0018-release-branch.go1.15-cmd-compile-fix-escape-analysi.patch
+++ /dev/null
@@ -1,87 +0,0 @@
-From f75ab2d5a61f1a5aabaffe7752110e2dcd581236 Mon Sep 17 00:00:00 2001
-From: Matthew Dempsky
-Date: Sat, 27 Feb 2021 09:41:19 -0800
-Subject: [PATCH 18/44] [release-branch.go1.15] cmd/compile: fix escape
- analysis of heap-allocated results
-
-One of escape analysis's responsibilities is to summarize whether/how
-each function parameter flows to the heap so we can correctly
-incorporate those flows into callers' escape analysis data flow
-graphs.
-
-As an optimization, we separately record when parameters flow to
-result parameters, so that we can more precisely analyze parameter
-flows based on how the results are used at the call site. However, if
-a named result parameter itself needs to be heap allocated, this
-optimization isn't safe and the parameter needs to be recorded as
-flowing to heap rather than flowing to result.
-
-Escape analysis used to get this correct because it conservatively
-rewalked the data-flow graph multiple times. So even though it would
-incorrectly record the result parameter flow, it would separately find
-a flow to the heap. However, CL 196811 (specifically, case 3)
-optimized the walking logic to reduce unnecessary rewalks causing us
-to stop finding the extra heap flow.
-
-This CL fixes the issue by correcting location.leakTo to be sensitive
-to sink.escapes and not record result-flows when the result parameter
-escapes to the heap.
-
-Fixes #44658.
-
-Change-Id: I48742ed35a6cab591094e2d23a439e205bd65c50
-Reviewed-on: https://go-review.googlesource.com/c/go/+/297289
-Trust: Matthew Dempsky
-Run-TryBot: Matthew Dempsky
-TryBot-Result: Go Bot
-Reviewed-by: Keith Randall
-Reviewed-on: https://go-review.googlesource.com/c/go/+/297291
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/f75ab2d5a61f1a5aabaffe7752110e2dcd581236
-
----
- src/cmd/compile/internal/gc/escape.go | 7 ++++---
- test/escape5.go | 11 +++++++++++
- 2 files changed, 15 insertions(+), 3 deletions(-)
-
-diff --git a/src/cmd/compile/internal/gc/escape.go b/src/cmd/compile/internal/gc/escape.go
-index 08000dd374..2c55163100 100644
---- a/src/cmd/compile/internal/gc/escape.go
-+++ b/src/cmd/compile/internal/gc/escape.go
-@@ -1379,9 +1379,10 @@ func containsClosure(f, c *Node) bool {
-
- // leak records that parameter l leaks to sink.
- func (l *EscLocation) leakTo(sink *EscLocation, derefs int) {
-- // If sink is a result parameter and we can fit return bits
-- // into the escape analysis tag, then record a return leak.
-- if sink.isName(PPARAMOUT) && sink.curfn == l.curfn {
-+ // If sink is a result parameter that doesn't escape (#44614)
-+ // and we can fit return bits into the escape analysis tag,
-+ // then record as a result leak.
-+ if !sink.escapes && sink.isName(PPARAMOUT) && sink.curfn == l.curfn {
- // TODO(mdempsky): Eliminate dependency on Vargen here.
- ri := int(sink.n.Name.Vargen) - 1
- if ri < numEscResults {
-diff --git a/test/escape5.go b/test/escape5.go
-index 061e57a069..145c5dd900 100644
---- a/test/escape5.go
-+++ b/test/escape5.go
-@@ -262,3 +262,14 @@ func f28369(n int) int {
-
- return 1 + f28369(n-1)
- }
-+
-+// Issue 44614: parameters that flow to a heap-allocated result
-+// parameter must be recorded as a heap-flow rather than a
-+// result-flow.
-+
-+// N.B., must match "leaking param: p",
-+// but *not* "leaking param: p to result r level=0".
-+func f(p *int) (r *int) { // ERROR "leaking param: p$" "moved to heap: r"
-+ sink4 = &r
-+ return p
-+}
---
-2.27.0
-
diff --git a/0076-release-branch.go1.17-syscall-check-correct-group-in.patch b/0018-release-branch.go1.17-syscall-check-correct-group-in.patch
similarity index 88%
rename from 0076-release-branch.go1.17-syscall-check-correct-group-in.patch
rename to 0018-release-branch.go1.17-syscall-check-correct-group-in.patch
index c6ec4dd0d2a21f70a947ed0723759eaaf79f1b6c..23872111deb09ff6cf9b92db33cd86301899934d 100644
--- a/0076-release-branch.go1.17-syscall-check-correct-group-in.patch
+++ b/0018-release-branch.go1.17-syscall-check-correct-group-in.patch
@@ -1,4 +1,4 @@
-From 77f1f0c3293857f1010dd1899d5a6dafbc21a378 Mon Sep 17 00:00:00 2001
+From 66cff0cda766c1533373fabf3bc26fc3397e55d5 Mon Sep 17 00:00:00 2001
From: Damien Neil
Date: Tue, 12 Apr 2022 13:38:17 -0700
Subject: [PATCH 2/2] [release-branch.go1.17] syscall: check correct group in
@@ -29,17 +29,17 @@ Run-TryBot: Damien Neil
Auto-Submit: Damien Neil
Reviewed-by: Tatiana Bradley
-Conflict: NA
-Reference: https://go-review.googlesource.com/c/go/+/401078/
+Reference:https://go-review.googlesource.com/c/go/+/401078/
+Conflict:NA
---
src/syscall/syscall_linux.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/syscall/syscall_linux.go b/src/syscall/syscall_linux.go
-index 07fe6a6c2b..dbf16d9af2 100644
+index dfce3d0a4b..3387f3bdc2 100644
--- a/src/syscall/syscall_linux.go
+++ b/src/syscall/syscall_linux.go
-@@ -106,7 +106,7 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
+@@ -109,7 +109,7 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
gid = Getgid()
}
diff --git a/0019-release-branch.go1.15-net-http-ignore-connection-clo.patch b/0019-release-branch.go1.15-net-http-ignore-connection-clo.patch
deleted file mode 100644
index 38b1bc7c774101e7df5a165f2fed7e01a7689985..0000000000000000000000000000000000000000
--- a/0019-release-branch.go1.15-net-http-ignore-connection-clo.patch
+++ /dev/null
@@ -1,124 +0,0 @@
-From 5de8d3bfcb060bbc61b9b9c945055fd3fb5b9607 Mon Sep 17 00:00:00 2001
-From: Michael Fraenkel
-Date: Sat, 26 Sep 2020 09:20:16 -0600
-Subject: [PATCH 19/44] [release-branch.go1.15] net/http: ignore connection
- closes once done with the connection
-
-Once the connection is put back into the idle pool, the request should
-not take any action if the connection is closed.
-
-For #42935.
-Updates #41600.
-
-Change-Id: I5e4ddcdc03cd44f5197ecfbe324638604961de84
-Reviewed-on: https://go-review.googlesource.com/c/go/+/257818
-Reviewed-by: Brad Fitzpatrick
-Trust: Damien Neil
-(cherry picked from commit 212d385a2f723a8dd5e7d2e83efb478ddd139349)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/297909
-Trust: Dmitri Shuralyov
-Run-TryBot: Dmitri Shuralyov
-Reviewed-by: Damien Neil
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/5de8d3bfcb060bbc61b9b9c945055fd3fb5b9607
-
----
- src/net/http/transport.go | 13 ++++++---
- src/net/http/transport_test.go | 51 ++++++++++++++++++++++++++++++++++
- 2 files changed, 60 insertions(+), 4 deletions(-)
-
-diff --git a/src/net/http/transport.go b/src/net/http/transport.go
-index d37b52b13d..6fb2ea5663 100644
---- a/src/net/http/transport.go
-+++ b/src/net/http/transport.go
-@@ -2560,6 +2560,7 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err
- var respHeaderTimer <-chan time.Time
- cancelChan := req.Request.Cancel
- ctxDoneChan := req.Context().Done()
-+ pcClosed := pc.closech
- for {
- testHookWaitResLoop()
- select {
-@@ -2579,11 +2580,15 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err
- defer timer.Stop() // prevent leaks
- respHeaderTimer = timer.C
- }
-- case <-pc.closech:
-- if debugRoundTrip {
-- req.logf("closech recv: %T %#v", pc.closed, pc.closed)
-+ case <-pcClosed:
-+ pcClosed = nil
-+ // check if we are still using the connection
-+ if pc.t.replaceReqCanceler(req.cancelKey, nil) {
-+ if debugRoundTrip {
-+ req.logf("closech recv: %T %#v", pc.closed, pc.closed)
-+ }
-+ return nil, pc.mapRoundTripError(req, startBytesWritten, pc.closed)
- }
-- return nil, pc.mapRoundTripError(req, startBytesWritten, pc.closed)
- case <-respHeaderTimer:
- if debugRoundTrip {
- req.logf("timeout waiting for response headers.")
-diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go
-index 0a47687d9a..3c7b9eb4de 100644
---- a/src/net/http/transport_test.go
-+++ b/src/net/http/transport_test.go
-@@ -6289,3 +6289,54 @@ func TestTransportRejectsSignInContentLength(t *testing.T) {
- t.Fatalf("Error mismatch\nGot: %q\nWanted substring: %q", got, want)
- }
- }
-+
-+// Issue 41600
-+// Test that a new request which uses the connection of an active request
-+// cannot cause it to be canceled as well.
-+func TestCancelRequestWhenSharingConnection(t *testing.T) {
-+ if testing.Short() {
-+ t.Skip("skipping in short mode")
-+ }
-+ ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, req *Request) {
-+ w.Header().Add("Content-Length", "0")
-+ }))
-+ defer ts.Close()
-+
-+ client := ts.Client()
-+ transport := client.Transport.(*Transport)
-+ transport.MaxIdleConns = 1
-+ transport.MaxConnsPerHost = 1
-+
-+ var wg sync.WaitGroup
-+
-+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
-+
-+ for i := 0; i < 10; i++ {
-+ wg.Add(1)
-+ go func() {
-+ defer wg.Done()
-+ for ctx.Err() == nil {
-+ reqctx, reqcancel := context.WithCancel(ctx)
-+ go reqcancel()
-+ req, _ := NewRequestWithContext(reqctx, "GET", ts.URL, nil)
-+ res, err := client.Do(req)
-+ if err == nil {
-+ res.Body.Close()
-+ }
-+ }
-+ }()
-+ }
-+
-+ for ctx.Err() == nil {
-+ req, _ := NewRequest("GET", ts.URL, nil)
-+ if res, err := client.Do(req); err != nil {
-+ t.Errorf("unexpected: %p %v", req, err)
-+ break
-+ } else {
-+ res.Body.Close()
-+ }
-+ }
-+
-+ cancel()
-+ wg.Wait()
-+}
---
-2.27.0
-
diff --git a/0078-release-branch.go1.18-net-http-update-bundled-golang.patch b/0019-release-branch.go1.18-net-http-update-bundled-golang.patch
similarity index 71%
rename from 0078-release-branch.go1.18-net-http-update-bundled-golang.patch
rename to 0019-release-branch.go1.18-net-http-update-bundled-golang.patch
index 0236818b28da8f3626f0995e87c59a4dc8c6084a..bb88ffd8f25334b9b38efb3a899543927ce056ad 100644
--- a/0078-release-branch.go1.18-net-http-update-bundled-golang.patch
+++ b/0019-release-branch.go1.18-net-http-update-bundled-golang.patch
@@ -1,4 +1,4 @@
-From 2afe499bc3ce4d9706e91b43522b6eca9ff4f43a Mon Sep 17 00:00:00 2001
+From b2058191785138021b635f609de3d5f651ec02cd Mon Sep 17 00:00:00 2001
From: Damien Neil
Date: Mon, 22 Aug 2022 16:21:02 -0700
Subject: [PATCH] [release-branch.go1.18] net/http: update bundled
@@ -21,17 +21,31 @@ Run-TryBot: Michael Knyszek
TryBot-Result: Gopher Robot
Reviewed-by: Carlos Amedee
-Conflict: NA
-Reference: https://go-review.googlesource.com/c/go/+/428635/
+Conflict:NA
+Reference:https://go-review.googlesource.com/c/go/+/428635/
---
- src/net/http/h2_bundle.go | 21 +++++++++++++--------
- 1 file changed, 13 insertions(+), 8 deletions(-)
+ src/cmd/internal/moddeps/moddeps_test.go | 2 ++
+ src/net/http/h2_bundle.go | 21 +++++++++++++--------
+ 2 files changed, 15 insertions(+), 8 deletions(-)
+diff --git a/src/cmd/internal/moddeps/moddeps_test.go b/src/cmd/internal/moddeps/moddeps_test.go
+index 56c3b2585c..3306e29431 100644
+--- a/src/cmd/internal/moddeps/moddeps_test.go
++++ b/src/cmd/internal/moddeps/moddeps_test.go
+@@ -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(#53977): 1.18.5 contains unreleased changes from vendored modules")
++
+ goBin := testenv.GoToolPath(t)
+
+ // Ensure that all packages imported within GOROOT
diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go
-index 06f8808dc6..dc30e077ae 100644
+index 1b73da7f21..d7e2f764c8 100644
--- a/src/net/http/h2_bundle.go
+++ b/src/net/http/h2_bundle.go
-@@ -3247,10 +3247,11 @@ func (s http2SettingID) String() string {
+@@ -3339,10 +3339,11 @@ func (s http2SettingID) String() string {
// name (key). See httpguts.ValidHeaderName for the base rules.
//
// Further, http2 says:
@@ -47,7 +61,7 @@ index 06f8808dc6..dc30e077ae 100644
func http2validWireHeaderFieldName(v string) bool {
if len(v) == 0 {
return false
-@@ -3441,8 +3442,8 @@ func (s *http2sorter) SortStrings(ss []string) {
+@@ -3533,8 +3534,8 @@ func (s *http2sorter) SortStrings(ss []string) {
// validPseudoPath reports whether v is a valid :path pseudo-header
// value. It must be either:
//
@@ -58,7 +72,7 @@ index 06f8808dc6..dc30e077ae 100644
//
// For now this is only used a quick check for deciding when to clean
// up Opaque URLs before sending requests from the Transport.
-@@ -4895,6 +4896,9 @@ func (sc *http2serverConn) startGracefulShutdownInternal() {
+@@ -4999,6 +5000,9 @@ func (sc *http2serverConn) startGracefulShutdownInternal() {
func (sc *http2serverConn) goAway(code http2ErrCode) {
sc.serveG.check()
if sc.inGoAway {
@@ -68,7 +82,7 @@ index 06f8808dc6..dc30e077ae 100644
return
}
sc.inGoAway = true
-@@ -6090,8 +6094,9 @@ func (rws *http2responseWriterState) writeChunk(p []byte) (n int, err error) {
+@@ -6211,8 +6215,9 @@ func (rws *http2responseWriterState) writeChunk(p []byte) (n int, err error) {
// prior to the headers being written. If the set of trailers is fixed
// or known before the header is written, the normal Go trailers mechanism
// is preferred:
diff --git a/0020-release-branch.go1.15-net-http-add-connections-back-.patch b/0020-release-branch.go1.15-net-http-add-connections-back-.patch
deleted file mode 100644
index f3b0198bc2a528fa9a23436fd422092107db2197..0000000000000000000000000000000000000000
--- a/0020-release-branch.go1.15-net-http-add-connections-back-.patch
+++ /dev/null
@@ -1,129 +0,0 @@
-From 1c60e0d928764b1b755c494d4a760eb51b99bc90 Mon Sep 17 00:00:00 2001
-From: Michael Fraenkel
-Date: Wed, 2 Dec 2020 17:07:27 -0700
-Subject: [PATCH 20/44] [release-branch.go1.15] net/http: add connections back
- that haven't been canceled
-
-Issue #41600 fixed the issue when a second request canceled a connection
-while the first request was still in roundTrip.
-This uncovered a second issue where a request was being canceled (in
-roundtrip) but the connection was put back into the idle pool for a
-subsequent request.
-The fix is the similar except its now in readLoop instead of roundTrip.
-A persistent connection is only added back if it successfully removed
-the cancel function; otherwise we know the roundTrip has started
-cancelRequest.
-
-Fixes #42935.
-Updates #42942.
-
-Change-Id: Ia56add20880ccd0c1ab812d380d8628e45f6f44c
-Reviewed-on: https://go-review.googlesource.com/c/go/+/274973
-Trust: Dmitri Shuralyov
-Trust: Damien Neil
-Reviewed-by: Damien Neil
-(cherry picked from commit 854a2f8e01a554d8052445563863775406a04b71)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/297910
-Run-TryBot: Dmitri Shuralyov
-TryBot-Result: Go Bot
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/1c60e0d928764b1b755c494d4a760eb51b99bc90
-
----
- src/net/http/transport.go | 22 ++++++++++++----------
- 1 file changed, 12 insertions(+), 10 deletions(-)
-
-diff --git a/src/net/http/transport.go b/src/net/http/transport.go
-index 6fb2ea5663..6e430b9885 100644
---- a/src/net/http/transport.go
-+++ b/src/net/http/transport.go
-@@ -766,7 +766,8 @@ func (t *Transport) CancelRequest(req *Request) {
- }
-
- // Cancel an in-flight request, recording the error value.
--func (t *Transport) cancelRequest(key cancelKey, err error) {
-+// Returns whether the request was canceled.
-+func (t *Transport) cancelRequest(key cancelKey, err error) bool {
- t.reqMu.Lock()
- cancel := t.reqCanceler[key]
- delete(t.reqCanceler, key)
-@@ -774,6 +775,8 @@ func (t *Transport) cancelRequest(key cancelKey, err error) {
- if cancel != nil {
- cancel(err)
- }
-+
-+ return cancel != nil
- }
-
- //
-@@ -2087,18 +2090,17 @@ func (pc *persistConn) readLoop() {
- }
-
- if !hasBody || bodyWritable {
-- pc.t.setReqCanceler(rc.cancelKey, nil)
-+ replaced := pc.t.replaceReqCanceler(rc.cancelKey, nil)
-
- // Put the idle conn back into the pool before we send the response
- // so if they process it quickly and make another request, they'll
- // get this same conn. But we use the unbuffered channel 'rc'
- // to guarantee that persistConn.roundTrip got out of its select
- // potentially waiting for this persistConn to close.
-- // but after
- alive = alive &&
- !pc.sawEOF &&
- pc.wroteRequest() &&
-- tryPutIdleConn(trace)
-+ replaced && tryPutIdleConn(trace)
-
- if bodyWritable {
- closeErr = errCallerOwnsConn
-@@ -2160,12 +2162,12 @@ func (pc *persistConn) readLoop() {
- // reading the response body. (or for cancellation or death)
- select {
- case bodyEOF := <-waitForBodyRead:
-- pc.t.setReqCanceler(rc.cancelKey, nil) // before pc might return to idle pool
-+ replaced := pc.t.replaceReqCanceler(rc.cancelKey, nil) // before pc might return to idle pool
- alive = alive &&
- bodyEOF &&
- !pc.sawEOF &&
- pc.wroteRequest() &&
-- tryPutIdleConn(trace)
-+ replaced && tryPutIdleConn(trace)
- if bodyEOF {
- eofc <- struct{}{}
- }
-@@ -2561,6 +2563,7 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err
- cancelChan := req.Request.Cancel
- ctxDoneChan := req.Context().Done()
- pcClosed := pc.closech
-+ canceled := false
- for {
- testHookWaitResLoop()
- select {
-@@ -2582,8 +2585,7 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err
- }
- case <-pcClosed:
- pcClosed = nil
-- // check if we are still using the connection
-- if pc.t.replaceReqCanceler(req.cancelKey, nil) {
-+ if canceled || pc.t.replaceReqCanceler(req.cancelKey, nil) {
- if debugRoundTrip {
- req.logf("closech recv: %T %#v", pc.closed, pc.closed)
- }
-@@ -2607,10 +2609,10 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err
- }
- return re.res, nil
- case <-cancelChan:
-- pc.t.cancelRequest(req.cancelKey, errRequestCanceled)
-+ canceled = pc.t.cancelRequest(req.cancelKey, errRequestCanceled)
- cancelChan = nil
- case <-ctxDoneChan:
-- pc.t.cancelRequest(req.cancelKey, req.Context().Err())
-+ canceled = pc.t.cancelRequest(req.cancelKey, req.Context().Err())
- cancelChan = nil
- ctxDoneChan = nil
- }
---
-2.27.0
-
diff --git a/0079-release-branch.go1.18-regexp-limit-size-of-parsed-re.patch b/0020-release-branch.go1.18-regexp-limit-size-of-parsed-re.patch
similarity index 72%
rename from 0079-release-branch.go1.18-regexp-limit-size-of-parsed-re.patch
rename to 0020-release-branch.go1.18-regexp-limit-size-of-parsed-re.patch
index 8696633fd3e726271a0aac9411b20f4df28a7c3c..436d179e6bff17d7fa124142248dc997ba68947d 100644
--- a/0079-release-branch.go1.18-regexp-limit-size-of-parsed-re.patch
+++ b/0020-release-branch.go1.18-regexp-limit-size-of-parsed-re.patch
@@ -1,4 +1,4 @@
-From 6a6f6943355ecca5fc6ca4538484edd492274b9a Mon Sep 17 00:00:00 2001
+From 8b3a5d153b7b255bafd1a82d61505088356d0458 Mon Sep 17 00:00:00 2001
From: Russ Cox
Date: Wed, 28 Sep 2022 11:18:51 -0400
Subject: [PATCH] regexp: limit size of parsed regexps
@@ -28,12 +28,12 @@ Reviewed-by: Dmitri Shuralyov
TryBot-Result: Gopher Robot
Reviewed-by: Dmitri Shuralyov
---
- src/regexp/syntax/parse.go | 164 +++++++++++++++++++++++++++++---
- src/regexp/syntax/parse_test.go | 13 ++-
- 2 files changed, 161 insertions(+), 16 deletions(-)
+ src/regexp/syntax/parse.go | 222 +++++++++++++++++++++++++++++++-
+ src/regexp/syntax/parse_test.go | 11 +-
+ 2 files changed, 224 insertions(+), 9 deletions(-)
diff --git a/src/regexp/syntax/parse.go b/src/regexp/syntax/parse.go
-index d7cf2af..67254d6 100644
+index 7b40309..67254d6 100644
--- a/src/regexp/syntax/parse.go
+++ b/src/regexp/syntax/parse.go
@@ -43,6 +43,7 @@ const (
@@ -44,10 +44,24 @@ index d7cf2af..67254d6 100644
)
func (e ErrorCode) String() string {
-@@ -90,15 +91,49 @@ const (
- // until we've allocated at least maxHeight Regexp structures.
- const maxHeight = 1000
+@@ -76,13 +77,63 @@ const (
+ opVerticalBar
+ )
++// maxHeight is the maximum height of a regexp parse tree.
++// It is somewhat arbitrarily chosen, but the idea is to be large enough
++// that no one will actually hit in real use but at the same time small enough
++// that recursion on the Regexp tree will not hit the 1GB Go stack limit.
++// The maximum amount of stack for a single recursive frame is probably
++// closer to 1kB, so this could potentially be raised, but it seems unlikely
++// that people have regexps nested even this deeply.
++// We ran a test on Google's C++ code base and turned up only
++// a single use case with depth > 100; it had depth 128.
++// Using depth 1000 should be plenty of margin.
++// As an optimization, we don't even bother calculating heights
++// until we've allocated at least maxHeight Regexp structures.
++const maxHeight = 1000
++
+// maxSize is the maximum size of a compiled regexp in Insts.
+// It too is somewhat arbitrarily chosen, but the idea is to be large enough
+// to allow significant regexps while at the same time small enough that
@@ -85,9 +99,7 @@ index d7cf2af..67254d6 100644
free *Regexp
numCap int // number of capturing groups seen
wholeRegexp string
-- tmpClass []rune // temporary char class work space
-- numRegexp int // number of regexps allocated
-- height map[*Regexp]int // regexp height for height limit check
+- tmpClass []rune // temporary char class work space
+ tmpClass []rune // temporary char class work space
+ numRegexp int // number of regexps allocated
+ numRunes int // number of runes in char classes
@@ -97,7 +109,21 @@ index d7cf2af..67254d6 100644
}
func (p *parser) newRegexp(op Op) *Regexp {
-@@ -122,6 +157,104 @@ func (p *parser) reuse(re *Regexp) {
+@@ -92,20 +143,155 @@ func (p *parser) newRegexp(op Op) *Regexp {
+ *re = Regexp{}
+ } else {
+ re = new(Regexp)
++ p.numRegexp++
+ }
+ re.Op = op
+ return re
+ }
+
+ func (p *parser) reuse(re *Regexp) {
++ if p.height != nil {
++ delete(p.height, re)
++ }
+ re.Sub0[0] = p.free
p.free = re
}
@@ -199,19 +225,39 @@ index d7cf2af..67254d6 100644
+ return size
+}
+
- func (p *parser) checkHeight(re *Regexp) {
- if p.numRegexp < maxHeight {
- return
-@@ -133,7 +266,7 @@ func (p *parser) checkHeight(re *Regexp) {
- }
- }
- if p.calcHeight(re, true) > maxHeight {
-- panic(ErrInternalError)
++func (p *parser) checkHeight(re *Regexp) {
++ if p.numRegexp < maxHeight {
++ return
++ }
++ if p.height == nil {
++ p.height = make(map[*Regexp]int)
++ for _, re := range p.stack {
++ p.checkHeight(re)
++ }
++ }
++ if p.calcHeight(re, true) > maxHeight {
+ panic(ErrNestingDepth)
- }
- }
-
-@@ -158,6 +291,7 @@ func (p *parser) calcHeight(re *Regexp, force bool) int {
++ }
++}
++
++func (p *parser) calcHeight(re *Regexp, force bool) int {
++ if !force {
++ if h, ok := p.height[re]; ok {
++ return h
++ }
++ }
++ h := 1
++ for _, sub := range re.Sub {
++ hsub := p.calcHeight(sub, false)
++ if h < 1+hsub {
++ h = 1 + hsub
++ }
++ }
++ p.height[re] = h
++ return h
++}
++
+ // Parse stack manipulation.
// push pushes the regexp re onto the parse stack and returns the regexp.
func (p *parser) push(re *Regexp) *Regexp {
@@ -219,25 +265,23 @@ index d7cf2af..67254d6 100644
if re.Op == OpCharClass && len(re.Rune) == 2 && re.Rune[0] == re.Rune[1] {
// Single rune.
if p.maybeConcat(re.Rune[0], p.flags&^FoldCase) {
-@@ -189,7 +323,7 @@ func (p *parser) push(re *Regexp) *Regexp {
+@@ -137,6 +323,7 @@ func (p *parser) push(re *Regexp) *Regexp {
}
p.stack = append(p.stack, re)
-- p.checkHeight(re)
+ p.checkLimits(re)
return re
}
-@@ -299,7 +433,7 @@ func (p *parser) repeat(op Op, min, max int, before, after, lastRepeat string) (
+@@ -246,6 +433,7 @@ func (p *parser) repeat(op Op, min, max int, before, after, lastRepeat string) (
re.Sub = re.Sub0[:1]
re.Sub[0] = sub
p.stack[n-1] = re
-- p.checkHeight(re)
+ p.checkLimits(re)
if op == OpRepeat && (min >= 2 || max >= 2) && !repeatIsValid(re, 1000) {
return "", &Error{ErrInvalidRepeatSize, before[:len(before)-len(after)]}
-@@ -444,12 +578,16 @@ func (p *parser) collapse(subs []*Regexp, op Op) *Regexp {
+@@ -390,12 +578,16 @@ func (p *parser) collapse(subs []*Regexp, op Op) *Regexp {
// frees (passes to p.reuse) any removed *Regexps.
//
// For example,
@@ -257,7 +301,7 @@ index d7cf2af..67254d6 100644
func (p *parser) factor(sub []*Regexp) []*Regexp {
if len(sub) < 2 {
return sub
-@@ -503,6 +641,7 @@ func (p *parser) factor(sub []*Regexp) []*Regexp {
+@@ -449,6 +641,7 @@ func (p *parser) factor(sub []*Regexp) []*Regexp {
for j := start; j < i; j++ {
sub[j] = p.removeLeadingString(sub[j], len(str))
@@ -265,7 +309,7 @@ index d7cf2af..67254d6 100644
}
suffix := p.collapse(sub[start:i], OpAlternate) // recurse
-@@ -560,6 +699,7 @@ func (p *parser) factor(sub []*Regexp) []*Regexp {
+@@ -506,6 +699,7 @@ func (p *parser) factor(sub []*Regexp) []*Regexp {
for j := start; j < i; j++ {
reuse := j != start // prefix came from sub[start]
sub[j] = p.removeLeadingRegexp(sub[j], reuse)
@@ -273,19 +317,39 @@ index d7cf2af..67254d6 100644
}
suffix := p.collapse(sub[start:i], OpAlternate) // recurse
-@@ -757,8 +897,10 @@ func parse(s string, flags Flags) (_ *Regexp, err error) {
- panic(r)
- case nil:
- // ok
-- case ErrInternalError:
+@@ -693,6 +887,23 @@ func literalRegexp(s string, flags Flags) *Regexp {
+ // Flags, and returns a regular expression parse tree. The syntax is
+ // described in the top-level comment.
+ func Parse(s string, flags Flags) (*Regexp, error) {
++ return parse(s, flags)
++}
++
++func parse(s string, flags Flags) (_ *Regexp, err error) {
++ defer func() {
++ switch r := recover(); r {
++ default:
++ panic(r)
++ case nil:
++ // ok
+ case ErrInternalError: // too big
- err = &Error{Code: ErrInternalError, Expr: s}
++ err = &Error{Code: ErrInternalError, Expr: s}
+ case ErrNestingDepth:
+ err = &Error{Code: ErrNestingDepth, Expr: s}
- }
- }()
-
-@@ -1801,7 +1943,7 @@ func appendClass(r []rune, x []rune) []rune {
++ }
++ }()
++
+ if flags&Literal != 0 {
+ // Trivial parser for literal string.
+ if err := checkUTF8(s); err != nil {
+@@ -704,7 +915,6 @@ func Parse(s string, flags Flags) (*Regexp, error) {
+ // Otherwise, must do real work.
+ var (
+ p parser
+- err error
+ c rune
+ op Op
+ lastRepeat string
+@@ -1733,7 +1943,7 @@ func appendClass(r []rune, x []rune) []rune {
return r
}
@@ -295,18 +359,16 @@ index d7cf2af..67254d6 100644
for i := 0; i < len(x); i += 2 {
r = appendFoldedRange(r, x[i], x[i+1])
diff --git a/src/regexp/syntax/parse_test.go b/src/regexp/syntax/parse_test.go
-index 1ef6d8a..67e3c56 100644
+index 5581ba1..6044da6 100644
--- a/src/regexp/syntax/parse_test.go
+++ b/src/regexp/syntax/parse_test.go
-@@ -484,12 +484,15 @@ var invalidRegexps = []string{
+@@ -479,10 +479,15 @@ var invalidRegexps = []string{
`(?P<>a)`,
`[a-Z]`,
`(?i)[a-Z]`,
- `a{100000}`,
- `a{100000,}`,
- "((((((((((x{2}){2}){2}){2}){2}){2}){2}){2}){2}){2})",
-- strings.Repeat("(", 1000) + strings.Repeat(")", 1000),
-- strings.Repeat("(?:", 1000) + strings.Repeat(")*", 1000),
`\Q\E*`,
+ `a{100000}`, // too much repetition
+ `a{100000,}`, // too much repetition
@@ -315,7 +377,7 @@ index 1ef6d8a..67e3c56 100644
+ strings.Repeat("(?:", 1000) + strings.Repeat(")*", 1000), // too deep
+ "(" + strings.Repeat("(xx?)", 1000) + "){1000}", // too long
+ strings.Repeat("(xx?){1000}", 1000), // too long
-+ strings.Repeat(`\pL`, 270000), // too many runes
++ strings.Repeat(`\pL`, 27000), // too many runes
}
var onlyPerl = []string{
diff --git a/0021-release-branch.go1.15-security-encoding-xml-prevent-.patch b/0021-release-branch.go1.15-security-encoding-xml-prevent-.patch
deleted file mode 100644
index 294539e68dc268a9e50c930cd9b4eb83898d44a6..0000000000000000000000000000000000000000
--- a/0021-release-branch.go1.15-security-encoding-xml-prevent-.patch
+++ /dev/null
@@ -1,189 +0,0 @@
-From 91062c2e4cbbf78a108919f6ed3ded1173937cf3 Mon Sep 17 00:00:00 2001
-From: Katie Hockman
-Date: Mon, 1 Mar 2021 09:54:00 -0500
-Subject: [PATCH 21/44] [release-branch.go1.15-security] encoding/xml: prevent
- infinite loop while decoding
-
-This change properly handles a TokenReader which
-returns an EOF in the middle of an open XML
-element.
-
-Thanks to Sam Whited for reporting this.
-
-Fixes CVE-2021-27918
-
-Change-Id: Id02a3f3def4a1b415fa2d9a8e3b373eb6cb0f433
-Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1004594
-Reviewed-by: Russ Cox
-Reviewed-by: Roland Shoemaker
-Reviewed-by: Filippo Valsorda
-(cherry picked from commit e7ce1f6746223ec7b4caa3b1ece25d9be3864710)
-Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1014236
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/91062c2e4cbbf78a108919f6ed3ded1173937cf3
-
----
- src/encoding/xml/xml.go | 19 ++++---
- src/encoding/xml/xml_test.go | 104 +++++++++++++++++++++++++++--------
- 2 files changed, 92 insertions(+), 31 deletions(-)
-
-diff --git a/src/encoding/xml/xml.go b/src/encoding/xml/xml.go
-index adaf4daf19..6f9594d7ba 100644
---- a/src/encoding/xml/xml.go
-+++ b/src/encoding/xml/xml.go
-@@ -271,7 +271,7 @@ func NewTokenDecoder(t TokenReader) *Decoder {
- // it will return an error.
- //
- // Token implements XML name spaces as described by
--// https://www.w3.org/TR/REC-xml-names/. Each of the
-+// https://www.w3.org/TR/REC-xml-names/. Each of the
- // Name structures contained in the Token has the Space
- // set to the URL identifying its name space when known.
- // If Token encounters an unrecognized name space prefix,
-@@ -285,16 +285,17 @@ func (d *Decoder) Token() (Token, error) {
- if d.nextToken != nil {
- t = d.nextToken
- d.nextToken = nil
-- } else if t, err = d.rawToken(); err != nil {
-- switch {
-- case err == io.EOF && d.t != nil:
-- err = nil
-- case err == io.EOF && d.stk != nil && d.stk.kind != stkEOF:
-- err = d.syntaxError("unexpected EOF")
-+ } else {
-+ if t, err = d.rawToken(); t == nil && err != nil {
-+ if err == io.EOF && d.stk != nil && d.stk.kind != stkEOF {
-+ err = d.syntaxError("unexpected EOF")
-+ }
-+ return nil, err
- }
-- return t, err
-+ // We still have a token to process, so clear any
-+ // errors (e.g. EOF) and proceed.
-+ err = nil
- }
--
- if !d.Strict {
- if t1, ok := d.autoClose(t); ok {
- d.nextToken = t
-diff --git a/src/encoding/xml/xml_test.go b/src/encoding/xml/xml_test.go
-index efddca43e9..5672ebb375 100644
---- a/src/encoding/xml/xml_test.go
-+++ b/src/encoding/xml/xml_test.go
-@@ -33,30 +33,90 @@ func (t *toks) Token() (Token, error) {
-
- func TestDecodeEOF(t *testing.T) {
- start := StartElement{Name: Name{Local: "test"}}
-- t.Run("EarlyEOF", func(t *testing.T) {
-- d := NewTokenDecoder(&toks{earlyEOF: true, t: []Token{
-- start,
-- start.End(),
-- }})
-- err := d.Decode(&struct {
-- XMLName Name `xml:"test"`
-- }{})
-- if err != nil {
-- t.Error(err)
-+ tests := []struct {
-+ name string
-+ tokens []Token
-+ ok bool
-+ }{
-+ {
-+ name: "OK",
-+ tokens: []Token{
-+ start,
-+ start.End(),
-+ },
-+ ok: true,
-+ },
-+ {
-+ name: "Malformed",
-+ tokens: []Token{
-+ start,
-+ StartElement{Name: Name{Local: "bad"}},
-+ start.End(),
-+ },
-+ ok: false,
-+ },
-+ }
-+ for _, tc := range tests {
-+ for _, eof := range []bool{true, false} {
-+ name := fmt.Sprintf("%s/earlyEOF=%v", tc.name, eof)
-+ t.Run(name, func(t *testing.T) {
-+ d := NewTokenDecoder(&toks{
-+ earlyEOF: eof,
-+ t: tc.tokens,
-+ })
-+ err := d.Decode(&struct {
-+ XMLName Name `xml:"test"`
-+ }{})
-+ if tc.ok && err != nil {
-+ t.Fatalf("d.Decode: expected nil error, got %v", err)
-+ }
-+ if _, ok := err.(*SyntaxError); !tc.ok && !ok {
-+ t.Errorf("d.Decode: expected syntax error, got %v", err)
-+ }
-+ })
- }
-- })
-- t.Run("LateEOF", func(t *testing.T) {
-- d := NewTokenDecoder(&toks{t: []Token{
-- start,
-- start.End(),
-- }})
-- err := d.Decode(&struct {
-- XMLName Name `xml:"test"`
-- }{})
-- if err != nil {
-- t.Error(err)
-+ }
-+}
-+
-+type toksNil struct {
-+ returnEOF bool
-+ t []Token
-+}
-+
-+func (t *toksNil) Token() (Token, error) {
-+ if len(t.t) == 0 {
-+ if !t.returnEOF {
-+ // Return nil, nil before returning an EOF. It's legal, but
-+ // discouraged.
-+ t.returnEOF = true
-+ return nil, nil
- }
-- })
-+ return nil, io.EOF
-+ }
-+ var tok Token
-+ tok, t.t = t.t[0], t.t[1:]
-+ return tok, nil
-+}
-+
-+func TestDecodeNilToken(t *testing.T) {
-+ for _, strict := range []bool{true, false} {
-+ name := fmt.Sprintf("Strict=%v", strict)
-+ t.Run(name, func(t *testing.T) {
-+ start := StartElement{Name: Name{Local: "test"}}
-+ bad := StartElement{Name: Name{Local: "bad"}}
-+ d := NewTokenDecoder(&toksNil{
-+ // Malformed
-+ t: []Token{start, bad, start.End()},
-+ })
-+ d.Strict = strict
-+ err := d.Decode(&struct {
-+ XMLName Name `xml:"test"`
-+ }{})
-+ if _, ok := err.(*SyntaxError); !ok {
-+ t.Errorf("d.Decode: expected syntax error, got %v", err)
-+ }
-+ })
-+ }
- }
-
- const testInput = `
---
-2.27.0
-
diff --git a/0080-release-branch.go1.18-net-http-httputil-avoid-query-.patch b/0021-release-branch.go1.18-net-http-httputil-avoid-query-.patch
similarity index 92%
rename from 0080-release-branch.go1.18-net-http-httputil-avoid-query-.patch
rename to 0021-release-branch.go1.18-net-http-httputil-avoid-query-.patch
index df193bc2524caffff991b554132411c9cadeca98..b07cf56be34db31d457fe07f457477c33be3122b 100644
--- a/0080-release-branch.go1.18-net-http-httputil-avoid-query-.patch
+++ b/0021-release-branch.go1.18-net-http-httputil-avoid-query-.patch
@@ -1,7 +1,7 @@
-From 61cdfc54fe4d7dd2179d3d6ae1d3ebb5709daad7 Mon Sep 17 00:00:00 2001
+From 51a477dc4f1130d53e66cd2003de0bac40e5e2be Mon Sep 17 00:00:00 2001
From: Damien Neil
Date: Thu, 22 Sep 2022 13:32:00 -0700
-Subject: [PATCH] [release-branch.go1.18] net/http/httputil: avoid query
+Subject: [PATCH 2/3] [release-branch.go1.18] net/http/httputil: avoid query
parameter smuggling
Query parameter smuggling occurs when a proxy's interpretation
@@ -37,10 +37,10 @@ Reviewed-by: Dmitri Shuralyov
2 files changed, 110 insertions(+)
diff --git a/src/net/http/httputil/reverseproxy.go b/src/net/http/httputil/reverseproxy.go
-index 68754cb088..5b42b76f37 100644
+index 8b63368386..c76eec6987 100644
--- a/src/net/http/httputil/reverseproxy.go
+++ b/src/net/http/httputil/reverseproxy.go
-@@ -248,6 +248,9 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
+@@ -249,6 +249,9 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
}
p.Director(outreq)
@@ -50,7 +50,7 @@ index 68754cb088..5b42b76f37 100644
outreq.Close = false
reqUpType := upgradeType(outreq.Header)
-@@ -614,3 +617,36 @@ func (c switchProtocolCopier) copyToBackend(errc chan<- error) {
+@@ -628,3 +631,36 @@ func (c switchProtocolCopier) copyToBackend(errc chan<- error) {
_, err := io.Copy(c.backend, c.user)
errc <- err
}
@@ -88,10 +88,10 @@ index 68754cb088..5b42b76f37 100644
+ return false
+}
diff --git a/src/net/http/httputil/reverseproxy_test.go b/src/net/http/httputil/reverseproxy_test.go
-index 1f2dfb9867..3dfd24df35 100644
+index 4b6ad77a29..8c0a4f136b 100644
--- a/src/net/http/httputil/reverseproxy_test.go
+++ b/src/net/http/httputil/reverseproxy_test.go
-@@ -1460,3 +1460,77 @@ func TestJoinURLPath(t *testing.T) {
+@@ -1517,3 +1517,77 @@ func TestJoinURLPath(t *testing.T) {
}
}
}
diff --git a/0081-release-branch.go1.18-archive-tar-limit-size-of-head.patch b/0022-release-branch.go1.18-archive-tar-limit-size-of-head.patch
similarity index 62%
rename from 0081-release-branch.go1.18-archive-tar-limit-size-of-head.patch
rename to 0022-release-branch.go1.18-archive-tar-limit-size-of-head.patch
index 93d520273692cf5f85964578af549ff69fb12dbb..550877a2761d619b88ba92186052542583d1ad5c 100644
--- a/0081-release-branch.go1.18-archive-tar-limit-size-of-head.patch
+++ b/0022-release-branch.go1.18-archive-tar-limit-size-of-head.patch
@@ -1,4 +1,4 @@
-From 61088cf9ed18b7b03dad384f2691a17f85fc24c5 Mon Sep 17 00:00:00 2001
+From 7dd44b287830fbb2256aceac4a36756b955c0279 Mon Sep 17 00:00:00 2001
From: Damien Neil
Date: Fri, 2 Sep 2022 20:45:18 -0700
Subject: [PATCH] archive/tar: limit size of headers
@@ -30,13 +30,12 @@ Reviewed-by: Dmitri Shuralyov
Run-TryBot: Carlos Amedee
TryBot-Result: Gopher Robot
---
- src/archive/tar/format.go | 4 +++
- src/archive/tar/reader.go | 20 ++++++++---
- src/archive/tar/reader_test.go | 11 +++++-
- src/archive/tar/writer.go | 3 ++
- src/archive/tar/writer_test.go | 27 ++++++++++++++
- src/io/io.go | 64 ++++++++++++++++++++++++++++++++++
- 6 files changed, 123 insertions(+), 6 deletions(-)
+ src/archive/tar/format.go | 4 ++++
+ src/archive/tar/reader.go | 14 ++++++++++++--
+ src/archive/tar/reader_test.go | 11 ++++++++++-
+ src/archive/tar/writer.go | 3 +++
+ src/archive/tar/writer_test.go | 27 +++++++++++++++++++++++++++
+ 5 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/src/archive/tar/format.go b/src/archive/tar/format.go
index cfe24a5..6642364 100644
@@ -54,41 +53,28 @@ index cfe24a5..6642364 100644
// blockPadding computes the number of bytes needed to pad offset up to the
diff --git a/src/archive/tar/reader.go b/src/archive/tar/reader.go
-index 4f9135b..ec45ae3 100644
+index 1b1d5b4..f645af8 100644
--- a/src/archive/tar/reader.go
+++ b/src/archive/tar/reader.go
-@@ -104,7 +104,7 @@ func (tr *Reader) next() (*Header, error) {
+@@ -103,7 +103,7 @@ func (tr *Reader) next() (*Header, error) {
continue // This is a meta header affecting the next header
case TypeGNULongName, TypeGNULongLink:
format.mayOnlyBe(FormatGNU)
-- realname, err := ioutil.ReadAll(tr)
+- realname, err := io.ReadAll(tr)
+ realname, err := readSpecialFile(tr)
if err != nil {
return nil, err
}
-@@ -294,7 +294,7 @@ func mergePAX(hdr *Header, paxHdrs map[string]string) (err error) {
+@@ -293,7 +293,7 @@ func mergePAX(hdr *Header, paxHdrs map[string]string) (err error) {
// parsePAX parses PAX headers.
// If an extended header (type 'x') is invalid, ErrHeader is returned
func parsePAX(r io.Reader) (map[string]string, error) {
-- buf, err := ioutil.ReadAll(r)
+- buf, err := io.ReadAll(r)
+ buf, err := readSpecialFile(r)
if err != nil {
return nil, err
}
-@@ -337,9 +337,9 @@ func parsePAX(r io.Reader) (map[string]string, error) {
- // header in case further processing is required.
- //
- // The err will be set to io.EOF only when one of the following occurs:
--// * Exactly 0 bytes are read and EOF is hit.
--// * Exactly 1 block of zeros is read and EOF is hit.
--// * At least 2 blocks of zeros are read.
-+// - Exactly 0 bytes are read and EOF is hit.
-+// - Exactly 1 block of zeros is read and EOF is hit.
-+// - At least 2 blocks of zeros are read.
- func (tr *Reader) readHeader() (*Header, *block, error) {
- // Two blocks of zero bytes marks the end of the archive.
- if _, err := io.ReadFull(tr.r, tr.blk[:]); err != nil {
-@@ -827,6 +827,16 @@ func tryReadFull(r io.Reader, b []byte) (n int, err error) {
+@@ -826,6 +826,16 @@ func tryReadFull(r io.Reader, b []byte) (n int, err error) {
return n, err
}
@@ -106,7 +92,7 @@ index 4f9135b..ec45ae3 100644
func discard(r io.Reader, n int64) error {
// If possible, Seek to the last byte before the end of the data section.
diff --git a/src/archive/tar/reader_test.go b/src/archive/tar/reader_test.go
-index f153b66..c68a859 100644
+index 789ddc1..5a644a4 100644
--- a/src/archive/tar/reader_test.go
+++ b/src/archive/tar/reader_test.go
@@ -6,6 +6,7 @@ package tar
@@ -117,7 +103,7 @@ index f153b66..c68a859 100644
"crypto/md5"
"errors"
"fmt"
-@@ -244,6 +245,9 @@ func TestReader(t *testing.T) {
+@@ -243,6 +244,9 @@ func TestReader(t *testing.T) {
}, {
file: "testdata/pax-bad-hdr-file.tar",
err: ErrHeader,
@@ -127,7 +113,7 @@ index f153b66..c68a859 100644
}, {
file: "testdata/pax-bad-mtime-file.tar",
err: ErrHeader,
-@@ -626,9 +630,14 @@ func TestReader(t *testing.T) {
+@@ -625,9 +629,14 @@ func TestReader(t *testing.T) {
}
defer f.Close()
@@ -158,10 +144,10 @@ index e80498d..893eac0 100644
return err // Global headers return here
}
diff --git a/src/archive/tar/writer_test.go b/src/archive/tar/writer_test.go
-index 30556d2..4bd69fd 100644
+index a00f02d..4e709e5 100644
--- a/src/archive/tar/writer_test.go
+++ b/src/archive/tar/writer_test.go
-@@ -1007,6 +1007,33 @@ func TestIssue12594(t *testing.T) {
+@@ -1006,6 +1006,33 @@ func TestIssue12594(t *testing.T) {
}
}
@@ -195,85 +181,6 @@ index 30556d2..4bd69fd 100644
// testNonEmptyWriter wraps an io.Writer and ensures that
// Write is never called with an empty buffer.
type testNonEmptyWriter struct{ io.Writer }
-diff --git a/src/io/io.go b/src/io/io.go
-index 3dea70b..f611ec9 100644
---- a/src/io/io.go
-+++ b/src/io/io.go
-@@ -14,6 +14,7 @@ package io
-
- import (
- "errors"
-+ "sync"
- )
-
- // Seek whence values.
-@@ -547,3 +548,66 @@ func (t *teeReader) Read(p []byte) (n int, err error) {
- }
- return
- }
-+
-+// Discard is a Writer on which all Write calls succeed
-+// without doing anything.
-+var Discard Writer = discard{}
-+
-+type discard struct{}
-+
-+// discard implements ReaderFrom as an optimization so Copy to
-+// io.Discard can avoid doing unnecessary work.
-+var _ ReaderFrom = discard{}
-+
-+func (discard) Write(p []byte) (int, error) {
-+ return len(p), nil
-+}
-+
-+func (discard) WriteString(s string) (int, error) {
-+ return len(s), nil
-+}
-+
-+var blackHolePool = sync.Pool{
-+ New: func() interface{} {
-+ b := make([]byte, 8192)
-+ return &b
-+ },
-+}
-+
-+func (discard) ReadFrom(r Reader) (n int64, err error) {
-+ bufp := blackHolePool.Get().(*[]byte)
-+ readSize := 0
-+ for {
-+ readSize, err = r.Read(*bufp)
-+ n += int64(readSize)
-+ if err != nil {
-+ blackHolePool.Put(bufp)
-+ if err == EOF {
-+ return n, nil
-+ }
-+ return
-+ }
-+ }
-+}
-+
-+// ReadAll reads from r until an error or EOF and returns the data it read.
-+// A successful call returns err == nil, not err == EOF. Because ReadAll is
-+// defined to read from src until EOF, it does not treat an EOF from Read
-+// as an error to be reported.
-+func ReadAll(r Reader) ([]byte, error) {
-+ b := make([]byte, 0, 512)
-+ for {
-+ if len(b) == cap(b) {
-+ // Add more capacity (let append pick how much).
-+ b = append(b, 0)[:len(b)]
-+ }
-+ n, err := r.Read(b[len(b):cap(b)])
-+ b = b[:len(b)+n]
-+ if err != nil {
-+ if err == EOF {
-+ err = nil
-+ }
-+ return b, err
-+ }
-+ }
-+}
--
2.33.0
diff --git a/0023-release-branch.go1.15-cmd-go-don-t-report-missing-st.patch b/0023-release-branch.go1.15-cmd-go-don-t-report-missing-st.patch
deleted file mode 100644
index 71642c7754b2049564dd838a781afd07bc682cbd..0000000000000000000000000000000000000000
--- a/0023-release-branch.go1.15-cmd-go-don-t-report-missing-st.patch
+++ /dev/null
@@ -1,121 +0,0 @@
-From ba3dc70dc5c9f2162024b09d6b13bda1f4575b01 Mon Sep 17 00:00:00 2001
-From: Jay Conrod
-Date: Thu, 4 Mar 2021 11:50:31 -0500
-Subject: [PATCH 23/44] [release-branch.go1.15] cmd/go: don't report missing
- std import errors for tidy and vendor
-
-'go mod tidy' and 'go mod vendor' normally report errors when a
-package can't be imported, even if the import appears in a file that
-wouldn't be compiled by the current version of Go. These errors are
-common for packages introduced in higher versions of Go, like "embed"
-in 1.16.
-
-This change causes 'go mod tidy' and 'go mod vendor' to ignore
-missing package errors if the import path appears to come from the
-standard library because it lacks a dot in the first path element.
-
-NOTE: This change is not a clean cherry-pick of CL 298749 because
-parts of modload were substantially rewritten after 1.15.
-
-Fixes #44792
-Updates #27063
-
-Change-Id: I61d6443e77ab95fd8c0d1514f57ef4c8885a77cc
-Reviewed-on: https://go-review.googlesource.com/c/go/+/298749
-Trust: Jay Conrod
-Run-TryBot: Jay Conrod
-Reviewed-by: Bryan C. Mills
-TryBot-Result: Go Bot
-(cherry picked from commit 56d52e661114be60fb1893b034ac0c5976b622af)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/298950
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/ba3dc70dc5c9f2162024b09d6b13bda1f4575b01
-
----
- src/cmd/go/internal/modcmd/tidy.go | 1 +
- src/cmd/go/internal/modcmd/vendor.go | 1 +
- src/cmd/go/internal/modload/init.go | 6 ++++++
- src/cmd/go/internal/modload/load.go | 5 +++++
- src/cmd/go/testdata/script/mod_tidy_error.txt | 4 ++--
- 5 files changed, 15 insertions(+), 2 deletions(-)
-
-diff --git a/src/cmd/go/internal/modcmd/tidy.go b/src/cmd/go/internal/modcmd/tidy.go
-index af2b04c0c2..5ff847485c 100644
---- a/src/cmd/go/internal/modcmd/tidy.go
-+++ b/src/cmd/go/internal/modcmd/tidy.go
-@@ -42,6 +42,7 @@ func runTidy(cmd *base.Command, args []string) {
- base.Fatalf("go mod tidy: no arguments allowed")
- }
-
-+ modload.SilenceMissingStdImports = true
- modload.LoadALL()
- modload.TidyBuildList()
- modTidyGoSum() // updates memory copy; WriteGoMod on next line flushes it out
-diff --git a/src/cmd/go/internal/modcmd/vendor.go b/src/cmd/go/internal/modcmd/vendor.go
-index 8509ceb7a8..5a5bb943a5 100644
---- a/src/cmd/go/internal/modcmd/vendor.go
-+++ b/src/cmd/go/internal/modcmd/vendor.go
-@@ -47,6 +47,7 @@ func runVendor(cmd *base.Command, args []string) {
- if len(args) != 0 {
- base.Fatalf("go mod vendor: vendor takes no arguments")
- }
-+ modload.SilenceMissingStdImports = true
- pkgs := modload.LoadVendor()
-
- vdir := filepath.Join(modload.ModRoot(), "vendor")
-diff --git a/src/cmd/go/internal/modload/init.go b/src/cmd/go/internal/modload/init.go
-index 664a2a1594..2360feef04 100644
---- a/src/cmd/go/internal/modload/init.go
-+++ b/src/cmd/go/internal/modload/init.go
-@@ -56,6 +56,12 @@ var (
- CmdModModule string // module argument for 'go mod init'
-
- allowMissingModuleImports bool
-+
-+ // SilenceMissingStdImports indicates that LoadALL should not print an error
-+ // or terminate the process if an imported package is missing, and the import
-+ // path looks like it might be in the standard library (perhaps in a future
-+ // Go version).
-+ SilenceMissingStdImports bool
- )
-
- // ModFile returns the parsed go.mod file.
-diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go
-index 30992e0cc2..e5ea1a6c23 100644
---- a/src/cmd/go/internal/modload/load.go
-+++ b/src/cmd/go/internal/modload/load.go
-@@ -433,6 +433,11 @@ func loadAll(testAll bool) []string {
- var paths []string
- for _, pkg := range loaded.pkgs {
- if pkg.err != nil {
-+ if impErr := (*ImportMissingError)(nil); SilenceMissingStdImports &&
-+ errors.As(pkg.err, &impErr) &&
-+ search.IsStandardImportPath(impErr.Path) {
-+ continue
-+ }
- base.Errorf("%s: %v", pkg.stackText(), pkg.err)
- continue
- }
-diff --git a/src/cmd/go/testdata/script/mod_tidy_error.txt b/src/cmd/go/testdata/script/mod_tidy_error.txt
-index b6c24ceaf7..395537b1a7 100644
---- a/src/cmd/go/testdata/script/mod_tidy_error.txt
-+++ b/src/cmd/go/testdata/script/mod_tidy_error.txt
-@@ -4,12 +4,12 @@ env GO111MODULE=on
- # 'go mod tidy' and 'go mod vendor' should not hide loading errors.
-
- ! go mod tidy
--stderr '^issue27063 imports\n\tnonexist: package nonexist is not in GOROOT \(.*\)'
-+! stderr 'package nonexist is not in GOROOT'
- stderr '^issue27063 imports\n\tnonexist.example.com: cannot find module providing package nonexist.example.com'
- stderr '^issue27063 imports\n\tissue27063/other imports\n\tother.example.com/nonexist: cannot find module providing package other.example.com/nonexist'
-
- ! go mod vendor
--stderr '^issue27063 imports\n\tnonexist: package nonexist is not in GOROOT \(.*\)'
-+! stderr 'package nonexist is not in GOROOT'
- stderr '^issue27063 imports\n\tnonexist.example.com: cannot find module providing package nonexist.example.com'
- stderr '^issue27063 imports\n\tissue27063/other imports\n\tother.example.com/nonexist: cannot find module providing package other.example.com/nonexist'
-
---
-2.27.0
-
diff --git a/0083-syscall-os-exec-reject-environment-variables-contain.patch b/0023-syscall-os-exec-reject-environment-variables-contain.patch
similarity index 68%
rename from 0083-syscall-os-exec-reject-environment-variables-contain.patch
rename to 0023-syscall-os-exec-reject-environment-variables-contain.patch
index 0d0a7324c9a094c52037fd0d7b1685a23008578e..50c3d7566db0ccfd43deb45c407a21c9ac98bb4c 100644
--- a/0083-syscall-os-exec-reject-environment-variables-contain.patch
+++ b/0023-syscall-os-exec-reject-environment-variables-contain.patch
@@ -1,4 +1,4 @@
-From 6157e640af242fd239cf2ff79f1760da81e69e32 Mon Sep 17 00:00:00 2001
+From 0c539fa7a4a9d29252523e41e073198195ba6691 Mon Sep 17 00:00:00 2001
From: Damien Neil
Date: Mon, 17 Oct 2022 17:38:29 -0700
Subject: [PATCH] syscall, os/exec: reject environment variables containing
@@ -34,12 +34,13 @@ Run-TryBot: Matthew Dempsky
Reviewed-by: Heschi Kreinick
Reference: https://go-review.googlesource.com/c/go/+/446916
-Conflict: src/os/exec/exec.go
+Conflict: src/os/exec/exec.go;src/syscall/exec_windows.go
---
- src/os/exec/env_test.go | 19 +++++++++++++------
- src/os/exec/exec.go | 38 +++++++++++++++++++++++++++++++++-----
- src/os/exec/exec_test.go | 9 +++++++++
- 3 files changed, 55 insertions(+), 11 deletions(-)
+ src/os/exec/env_test.go | 19 +++++++++++++------
+ src/os/exec/exec.go | 38 ++++++++++++++++++++++++++++++++-----
+ src/os/exec/exec_test.go | 9 +++++++++
+ src/syscall/exec_windows.go | 20 ++++++++++++++-----
+ 4 files changed, 70 insertions(+), 16 deletions(-)
diff --git a/src/os/exec/env_test.go b/src/os/exec/env_test.go
index b5ac398..47b7c04 100644
@@ -163,10 +164,10 @@ index 0c49575..6f5c61b 100644
+ return env
+}
diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go
-index dafbc64..8cdecdb 100644
+index d854e0d..d03eab2 100644
--- a/src/os/exec/exec_test.go
+++ b/src/os/exec/exec_test.go
-@@ -1107,6 +1107,15 @@ func TestDedupEnvEcho(t *testing.T) {
+@@ -1104,6 +1104,15 @@ func TestDedupEnvEcho(t *testing.T) {
}
}
@@ -182,6 +183,66 @@ index dafbc64..8cdecdb 100644
func TestString(t *testing.T) {
echoPath, err := exec.LookPath("echo")
if err != nil {
+diff --git a/src/syscall/exec_windows.go b/src/syscall/exec_windows.go
+index 9d10d6a..50892be 100644
+--- a/src/syscall/exec_windows.go
++++ b/src/syscall/exec_windows.go
+@@ -7,6 +7,7 @@
+ package syscall
+
+ import (
++ "internal/bytealg"
+ "runtime"
+ "sync"
+ "unicode/utf16"
+@@ -115,12 +116,16 @@ func makeCmdLine(args []string) string {
+ // the representation required by CreateProcess: a sequence of NUL
+ // terminated strings followed by a nil.
+ // Last bytes are two UCS-2 NULs, or four NUL bytes.
+-func createEnvBlock(envv []string) *uint16 {
++// If any string contains a NUL, it returns (nil, EINVAL).
++func createEnvBlock(envv []string) (*uint16, error) {
+ if len(envv) == 0 {
+- return &utf16.Encode([]rune("\x00\x00"))[0]
++ return &utf16.Encode([]rune("\x00\x00"))[0], nil
+ }
+ length := 0
+ for _, s := range envv {
++ if bytealg.IndexByteString(s, 0) != -1 {
++ return nil, EINVAL
++ }
+ length += len(s) + 1
+ }
+ length += 1
+@@ -135,7 +140,7 @@ func createEnvBlock(envv []string) *uint16 {
+ }
+ copy(b[i:i+1], []byte{0})
+
+- return &utf16.Encode([]rune(string(b)))[0]
++ return &utf16.Encode([]rune(string(b)))[0], nil
+ }
+
+ func CloseOnExec(fd Handle) {
+@@ -400,12 +405,17 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
+ }
+ }
+
++ envBlock, err := createEnvBlock(attr.Env)
++ if err != nil {
++ return 0, 0, err
++ }
++
+ pi := new(ProcessInformation)
+ flags := sys.CreationFlags | CREATE_UNICODE_ENVIRONMENT | _EXTENDED_STARTUPINFO_PRESENT
+ if sys.Token != 0 {
+- err = CreateProcessAsUser(sys.Token, argv0p, argvp, sys.ProcessAttributes, sys.ThreadAttributes, willInheritHandles, flags, createEnvBlock(attr.Env), dirp, &si.StartupInfo, pi)
++ err = CreateProcessAsUser(sys.Token, argv0p, argvp, sys.ProcessAttributes, sys.ThreadAttributes, willInheritHandles, flags, envBlock, dirp, &si.StartupInfo, pi)
+ } else {
+- err = CreateProcess(argv0p, argvp, sys.ProcessAttributes, sys.ThreadAttributes, willInheritHandles, flags, createEnvBlock(attr.Env), dirp, &si.StartupInfo, pi)
++ err = CreateProcess(argv0p, argvp, sys.ProcessAttributes, sys.ThreadAttributes, willInheritHandles, flags, envBlock, dirp, &si.StartupInfo, pi)
+ }
+ if err != nil {
+ return 0, 0, err
--
2.33.0
diff --git a/0024-release-branch.go1.18-add-definition-byte-string-cut.patch b/0024-release-branch.go1.18-add-definition-byte-string-cut.patch
new file mode 100644
index 0000000000000000000000000000000000000000..7f2be9c2404a51742b917e8a5bc48cd9c29fcb19
--- /dev/null
+++ b/0024-release-branch.go1.18-add-definition-byte-string-cut.patch
@@ -0,0 +1,430 @@
+From 2a7b541156a736984296282b816beac3dead4e8e Mon Sep 17 00:00:00 2001
+From: root
+Date: Fri, 16 Dec 2022 18:14:16 +0800
+Subject: [PATCH] xxx
+
+Conflict: NA
+Reference:https://github.com/golang/go/commit/8e36ab055162efa6f67f3b9ee62f625ac8874901
+
+---
+ src/bytes/bytes.go | 14 ++++
+ src/bytes/bytes_test.go | 23 ++++++
+ src/bytes/example_test.go | 139 ++++++++++++++++++------------------
+ src/strings/example_test.go | 58 +++++++++------
+ src/strings/strings.go | 11 +++
+ src/strings/strings_test.go | 25 ++++++-
+ 6 files changed, 179 insertions(+), 91 deletions(-)
+
+diff --git a/src/bytes/bytes.go b/src/bytes/bytes.go
+index ce52649..50b43a4 100644
+--- a/src/bytes/bytes.go
++++ b/src/bytes/bytes.go
+@@ -1174,3 +1174,17 @@ func Index(s, sep []byte) int {
+ }
+ return -1
+ }
++
++
++// Cut slices s around the first instance of sep,
++// returning the text before and after sep.
++// The found result reports whether sep appears in s.
++// If sep does not appear in s, cut returns s, "", false.
++//
++// Cut returns slices of the original slice s, not copies.
++func Cut(s, sep []byte) (before, after []byte, found bool) {
++ if i := Index(s, sep); i >= 0 {
++ return s[:i], s[i+len(sep):], true
++ }
++ return s, nil, false
++}
+diff --git a/src/bytes/bytes_test.go b/src/bytes/bytes_test.go
+index 544ee46..538e613 100644
+--- a/src/bytes/bytes_test.go
++++ b/src/bytes/bytes_test.go
+@@ -1565,6 +1565,29 @@ func TestEqualFold(t *testing.T) {
+ }
+ }
+
++var cutTests = []struct {
++ s, sep string
++ before, after string
++ found bool
++}{
++ {"abc", "b", "a", "c", true},
++ {"abc", "a", "", "bc", true},
++ {"abc", "c", "ab", "", true},
++ {"abc", "abc", "", "", true},
++ {"abc", "", "", "abc", true},
++ {"abc", "d", "abc", "", false},
++ {"", "d", "", "", false},
++ {"", "", "", "", true},
++}
++
++func TestCut(t *testing.T) {
++ for _, tt := range cutTests {
++ if before, after, found := Cut([]byte(tt.s), []byte(tt.sep)); string(before) != tt.before || string(after) != tt.after || found != tt.found {
++ t.Errorf("Cut(%q, %q) = %q, %q, %v, want %q, %q, %v", tt.s, tt.sep, before, after, found, tt.before, tt.after, tt.found)
++ }
++ }
++}
++
+ func TestBufferGrowNegative(t *testing.T) {
+ defer func() {
+ if err := recover(); err == nil {
+diff --git a/src/bytes/example_test.go b/src/bytes/example_test.go
+index ae93202..82de99d 100644
+--- a/src/bytes/example_test.go
++++ b/src/bytes/example_test.go
+@@ -92,36 +92,6 @@ func ExampleCompare_search() {
+ }
+ }
+
+-func ExampleTrimSuffix() {
+- var b = []byte("Hello, goodbye, etc!")
+- b = bytes.TrimSuffix(b, []byte("goodbye, etc!"))
+- b = bytes.TrimSuffix(b, []byte("gopher"))
+- b = append(b, bytes.TrimSuffix([]byte("world!"), []byte("x!"))...)
+- os.Stdout.Write(b)
+- // Output: Hello, world!
+-}
+-
+-func ExampleTrimPrefix() {
+- var b = []byte("Goodbye,, world!")
+- b = bytes.TrimPrefix(b, []byte("Goodbye,"))
+- b = bytes.TrimPrefix(b, []byte("See ya,"))
+- fmt.Printf("Hello%s", b)
+- // Output: Hello, world!
+-}
+-
+-func ExampleFields() {
+- fmt.Printf("Fields are: %q", bytes.Fields([]byte(" foo bar baz ")))
+- // Output: Fields are: ["foo" "bar" "baz"]
+-}
+-
+-func ExampleFieldsFunc() {
+- f := func(c rune) bool {
+- return !unicode.IsLetter(c) && !unicode.IsNumber(c)
+- }
+- fmt.Printf("Fields are: %q", bytes.FieldsFunc([]byte(" foo1;bar2,baz3..."), f))
+- // Output: Fields are: ["foo1" "bar2" "baz3"]
+-}
+-
+ func ExampleContains() {
+ fmt.Println(bytes.Contains([]byte("seafood"), []byte("foo")))
+ fmt.Println(bytes.Contains([]byte("seafood"), []byte("bar")))
+@@ -168,6 +138,22 @@ func ExampleCount() {
+ // 5
+ }
+
++func ExampleCut() {
++ show := func(s, sep string) {
++ before, after, found := bytes.Cut([]byte(s), []byte(sep))
++ fmt.Printf("Cut(%q, %q) = %q, %q, %v\n", s, sep, before, after, found)
++ }
++ show("Gopher", "Go")
++ show("Gopher", "ph")
++ show("Gopher", "er")
++ show("Gopher", "Badger")
++ // Output:
++ // Cut("Gopher", "Go") = "", "pher", true
++ // Cut("Gopher", "ph") = "Go", "er", true
++ // Cut("Gopher", "er") = "Goph", "", true
++ // Cut("Gopher", "Badger") = "Gopher", "", false
++}
++
+ func ExampleEqual() {
+ fmt.Println(bytes.Equal([]byte("Go"), []byte("Go")))
+ fmt.Println(bytes.Equal([]byte("Go"), []byte("C++")))
+@@ -181,6 +167,19 @@ func ExampleEqualFold() {
+ // Output: true
+ }
+
++func ExampleFields() {
++ fmt.Printf("Fields are: %q", bytes.Fields([]byte(" foo bar baz ")))
++ // Output: Fields are: ["foo" "bar" "baz"]
++}
++
++func ExampleFieldsFunc() {
++ f := func(c rune) bool {
++ return !unicode.IsLetter(c) && !unicode.IsNumber(c)
++ }
++ fmt.Printf("Fields are: %q", bytes.FieldsFunc([]byte(" foo1;bar2,baz3..."), f))
++ // Output: Fields are: ["foo1" "bar2" "baz3"]
++}
++
+ func ExampleHasPrefix() {
+ fmt.Println(bytes.HasPrefix([]byte("Gopher"), []byte("Go")))
+ fmt.Println(bytes.HasPrefix([]byte("Gopher"), []byte("C")))
+@@ -246,6 +245,12 @@ func ExampleIndexRune() {
+ // -1
+ }
+
++func ExampleJoin() {
++ s := [][]byte{[]byte("foo"), []byte("bar"), []byte("baz")}
++ fmt.Printf("%s", bytes.Join(s, []byte(", ")))
++ // Output: foo, bar, baz
++}
++
+ func ExampleLastIndex() {
+ fmt.Println(bytes.Index([]byte("go gopher"), []byte("go")))
+ fmt.Println(bytes.LastIndex([]byte("go gopher"), []byte("go")))
+@@ -286,10 +291,12 @@ func ExampleLastIndexFunc() {
+ // -1
+ }
+
+-func ExampleJoin() {
+- s := [][]byte{[]byte("foo"), []byte("bar"), []byte("baz")}
+- fmt.Printf("%s", bytes.Join(s, []byte(", ")))
+- // Output: foo, bar, baz
++func ExampleReader_Len() {
++ fmt.Println(bytes.NewReader([]byte("Hi!")).Len())
++ fmt.Println(bytes.NewReader([]byte("こんにちは!")).Len())
++ // Output:
++ // 3
++ // 16
+ }
+
+ func ExampleRepeat() {
+@@ -399,20 +406,6 @@ func ExampleTrimFunc() {
+ // go-gopher!
+ }
+
+-func ExampleMap() {
+- rot13 := func(r rune) rune {
+- switch {
+- case r >= 'A' && r <= 'Z':
+- return 'A' + (r-'A'+13)%26
+- case r >= 'a' && r <= 'z':
+- return 'a' + (r-'a'+13)%26
+- }
+- return r
+- }
+- fmt.Printf("%s", bytes.Map(rot13, []byte("'Twas brillig and the slithy gopher...")))
+- // Output: 'Gjnf oevyyvt naq gur fyvgul tbcure...
+-}
+-
+ func ExampleTrimLeft() {
+ fmt.Print(string(bytes.TrimLeft([]byte("453gopher8257"), "0123456789")))
+ // Output:
+@@ -429,11 +422,28 @@ func ExampleTrimLeftFunc() {
+ // go-gopher!567
+ }
+
++func ExampleTrimPrefix() {
++ var b = []byte("Goodbye,, world!")
++ b = bytes.TrimPrefix(b, []byte("Goodbye,"))
++ b = bytes.TrimPrefix(b, []byte("See ya,"))
++ fmt.Printf("Hello%s", b)
++ // Output: Hello, world!
++}
++
+ func ExampleTrimSpace() {
+ fmt.Printf("%s", bytes.TrimSpace([]byte(" \t\n a lone gopher \n\t\r\n")))
+ // Output: a lone gopher
+ }
+
++func ExampleTrimSuffix() {
++ var b = []byte("Hello, goodbye, etc!")
++ b = bytes.TrimSuffix(b, []byte("goodbye, etc!"))
++ b = bytes.TrimSuffix(b, []byte("gopher"))
++ b = append(b, bytes.TrimSuffix([]byte("world!"), []byte("x!"))...)
++ os.Stdout.Write(b)
++ // Output: Hello, world!
++}
++
+ func ExampleTrimRight() {
+ fmt.Print(string(bytes.TrimRight([]byte("453gopher8257"), "0123456789")))
+ // Output:
+@@ -450,21 +460,6 @@ func ExampleTrimRightFunc() {
+ // 1234go-gopher!
+ }
+
+-func ExampleToUpper() {
+- fmt.Printf("%s", bytes.ToUpper([]byte("Gopher")))
+- // Output: GOPHER
+-}
+-
+-func ExampleToUpperSpecial() {
+- str := []byte("ahoj vývojári golang")
+- totitle := bytes.ToUpperSpecial(unicode.AzeriCase, str)
+- fmt.Println("Original : " + string(str))
+- fmt.Println("ToUpper : " + string(totitle))
+- // Output:
+- // Original : ahoj vývojári golang
+- // ToUpper : AHOJ VÝVOJÁRİ GOLANG
+-}
+-
+ func ExampleToLower() {
+ fmt.Printf("%s", bytes.ToLower([]byte("Gopher")))
+ // Output: gopher
+@@ -480,10 +475,16 @@ func ExampleToLowerSpecial() {
+ // ToLower : ahoj vývojári golang
+ }
+
+-func ExampleReader_Len() {
+- fmt.Println(bytes.NewReader([]byte("Hi!")).Len())
+- fmt.Println(bytes.NewReader([]byte("こんにちは!")).Len())
+- // Output:
+- // 3
+- // 16
++func ExampleToUpper() {
++ fmt.Printf("%s", bytes.ToUpper([]byte("Gopher")))
++ // Output: GOPHER
++}
++
++func ExampleToUpperSpecial() {
++ str := []byte("ahoj vyvojári golang")
++ totitle := bytes.ToUpperSpecial(unicode.AzeriCase, str)
++ fmt.Println("Original : " + string(str))
++ fmt.Println("ToUpper : " + string(totitle))
++ // Original : ahoj vyvojári golang
++ // ToUpper : AHOJ VYVOJáR? GOLANG
+ }
+diff --git a/src/strings/example_test.go b/src/strings/example_test.go
+index 375f9ca..b75424a 100644
+--- a/src/strings/example_test.go
++++ b/src/strings/example_test.go
+@@ -9,18 +9,15 @@ import (
+ "strings"
+ "unicode"
+ )
+-
+-func ExampleFields() {
+- fmt.Printf("Fields are: %q", strings.Fields(" foo bar baz "))
+- // Output: Fields are: ["foo" "bar" "baz"]
+-}
+-
+-func ExampleFieldsFunc() {
+- f := func(c rune) bool {
+- return !unicode.IsLetter(c) && !unicode.IsNumber(c)
++func ExampleBuilder() {
++ var b strings.Builder
++ for i := 3; i >= 1; i-- {
++ fmt.Fprintf(&b, "%d...", i)
+ }
+- fmt.Printf("Fields are: %q", strings.FieldsFunc(" foo1;bar2,baz3...", f))
+- // Output: Fields are: ["foo1" "bar2" "baz3"]
++ b.WriteString("ignition")
++ fmt.Println(b.String())
++
++ // Output: 3...2...1...ignition
+ }
+
+ func ExampleCompare() {
+@@ -79,11 +76,40 @@ func ExampleCount() {
+ // 5
+ }
+
++func ExampleCut() {
++ show := func(s, sep string) {
++ before, after, found := strings.Cut(s, sep)
++ fmt.Printf("Cut(%q, %q) = %q, %q, %v\n", s, sep, before, after, found)
++ }
++ show("Gopher", "Go")
++ show("Gopher", "ph")
++ show("Gopher", "er")
++ show("Gopher", "Badger")
++ // Output:
++ // Cut("Gopher", "Go") = "", "pher", true
++ // Cut("Gopher", "ph") = "Go", "er", true
++ // Cut("Gopher", "er") = "Goph", "", true
++ // Cut("Gopher", "Badger") = "Gopher", "", false
++}
++
+ func ExampleEqualFold() {
+ fmt.Println(strings.EqualFold("Go", "go"))
+ // Output: true
+ }
+
++func ExampleFields() {
++ fmt.Printf("Fields are: %q", strings.Fields(" foo bar baz "))
++ // Output: Fields are: ["foo" "bar" "baz"]
++}
++
++func ExampleFieldsFunc() {
++ f := func(c rune) bool {
++ return !unicode.IsLetter(c) && !unicode.IsNumber(c)
++ }
++ fmt.Printf("Fields are: %q", strings.FieldsFunc(" foo1;bar2,baz3...", f))
++ // Output: Fields are: ["foo1" "bar2" "baz3"]
++}
++
+ func ExampleHasPrefix() {
+ fmt.Println(strings.HasPrefix("Gopher", "Go"))
+ fmt.Println(strings.HasPrefix("Gopher", "C"))
+@@ -370,14 +396,3 @@ func ExampleTrimRightFunc() {
+ }))
+ // Output: ¡¡¡Hello, Gophers
+ }
+-
+-func ExampleBuilder() {
+- var b strings.Builder
+- for i := 3; i >= 1; i-- {
+- fmt.Fprintf(&b, "%d...", i)
+- }
+- b.WriteString("ignition")
+- fmt.Println(b.String())
+-
+- // Output: 3...2...1...ignition
+-}
+diff --git a/src/strings/strings.go b/src/strings/strings.go
+index b429735..0c94395 100644
+--- a/src/strings/strings.go
++++ b/src/strings/strings.go
+@@ -1100,3 +1100,14 @@ func Index(s, substr string) int {
+ }
+ return -1
+ }
++
++// Cut slices s around the first instance of sep,
++// returning the text before and after sep.
++// The found result reports whether sep appears in s.
++// If sep does not appear in s, cut returns s, "", false.
++func Cut(s, sep string) (before, after string, found bool) {
++ if i := Index(s, sep); i >= 0 {
++ return s[:i], s[i+len(sep):], true
++ }
++ return s, "", false
++}
+diff --git a/src/strings/strings_test.go b/src/strings/strings_test.go
+index 09e5b27..1ebce42 100644
+--- a/src/strings/strings_test.go
++++ b/src/strings/strings_test.go
+@@ -1577,11 +1577,34 @@ var CountTests = []struct {
+ func TestCount(t *testing.T) {
+ for _, tt := range CountTests {
+ if num := Count(tt.s, tt.sep); num != tt.num {
+- t.Errorf("Count(\"%s\", \"%s\") = %d, want %d", tt.s, tt.sep, num, tt.num)
++ t.Errorf("Count(%q, %q) = %d, want %d", tt.s, tt.sep, num, tt.num)
+ }
+ }
+ }
+
++var cutTests = []struct {
++ s, sep string
++ before, after string
++ found bool
++}{
++ {"abc", "b", "a", "c", true},
++ {"abc", "a", "", "bc", true},
++ {"abc", "c", "ab", "", true},
++ {"abc", "abc", "", "", true},
++ {"abc", "", "", "abc", true},
++ {"abc", "d", "abc", "", false},
++ {"", "d", "", "", false},
++ {"", "", "", "", true},
++}
++
++func TestCut(t *testing.T) {
++ for _, tt := range cutTests {
++ if before, after, found := Cut(tt.s, tt.sep); before != tt.before || after != tt.after || found != tt.found {
++ t.Errorf("Cut(%q, %q) = %q, %q, %v, want %q, %q, %v", tt.s, tt.sep, before, after, found, tt.before, tt.after, tt.found)
++ }
++ }
++}
++
+ func makeBenchInputHard() string {
+ tokens := [...]string{
+ "", "", "", "",
+--
+2.27.0
diff --git a/0025-release-branch.go1.15-cmd-go-internal-modfetch-detec.patch b/0025-release-branch.go1.15-cmd-go-internal-modfetch-detec.patch
deleted file mode 100644
index 9cf8ece8a9977690bf4cb9ecb8940397779d3f13..0000000000000000000000000000000000000000
--- a/0025-release-branch.go1.15-cmd-go-internal-modfetch-detec.patch
+++ /dev/null
@@ -1,310 +0,0 @@
-From 7038a380bcd0183842471c1984da491e044d3d34 Mon Sep 17 00:00:00 2001
-From: Jay Conrod
-Date: Wed, 3 Mar 2021 16:30:22 -0500
-Subject: [PATCH 25/44] [release-branch.go1.15] cmd/go/internal/modfetch:
- detect and recover from missing ziphash file
-
-Previously, if an extracted module directory existed in the module
-cache, but the corresponding ziphash file did not, if the sum was
-missing from go.sum, we would not verify the sum. This caused 'go get'
-not to write missing sums. 'go build' in readonly mode (now the
-default) checks for missing sums and doesn't attempt to fetch modules
-that can't be verified against go.sum.
-
-With this change, when requesting the module directory with
-modfetch.DownloadDir, if the ziphash file is missing, the go command
-will re-hash the zip without downloading or re-extracting it again.
-
-Note that the go command creates the ziphash file before the module
-directory, but another program could remove it separately, and it
-might not be present after a crash.
-
-Fixes #44872
-
-Change-Id: I64551e048a3ba17d069de1ec123d5b8b2757543c
-Reviewed-on: https://go-review.googlesource.com/c/go/+/298352
-Trust: Jay Conrod
-Run-TryBot: Jay Conrod
-TryBot-Result: Go Bot
-Reviewed-by: Bryan C. Mills
-(cherry picked from commit 302a400316319501748c0f034464fa70e7815272)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/299830
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/7038a380bcd0183842471c1984da491e044d3d34
-
----
- src/cmd/go/internal/modfetch/cache.go | 17 ++++
- src/cmd/go/internal/modfetch/fetch.go | 77 ++++++++++++-------
- .../script/mod_get_missing_ziphash.txt | 55 +++++++++++++
- src/cmd/go/testdata/script/mod_verify.txt | 7 +-
- 4 files changed, 125 insertions(+), 31 deletions(-)
- create mode 100644 src/cmd/go/testdata/script/mod_get_missing_ziphash.txt
-
-diff --git a/src/cmd/go/internal/modfetch/cache.go b/src/cmd/go/internal/modfetch/cache.go
-index e3074b775e..0b64a6943b 100644
---- a/src/cmd/go/internal/modfetch/cache.go
-+++ b/src/cmd/go/internal/modfetch/cache.go
-@@ -83,6 +83,7 @@ func DownloadDir(m module.Version) (string, error) {
- return "", err
- }
-
-+ // Check whether the directory itself exists.
- dir := filepath.Join(cfg.GOMODCACHE, enc+"@"+encVer)
- if fi, err := os.Stat(dir); os.IsNotExist(err) {
- return dir, err
-@@ -91,6 +92,9 @@ func DownloadDir(m module.Version) (string, error) {
- } else if !fi.IsDir() {
- return dir, &DownloadDirPartialError{dir, errors.New("not a directory")}
- }
-+
-+ // Check if a .partial file exists. This is created at the beginning of
-+ // a download and removed after the zip is extracted.
- partialPath, err := CachePath(m, "partial")
- if err != nil {
- return dir, err
-@@ -100,6 +104,19 @@ func DownloadDir(m module.Version) (string, error) {
- } else if !os.IsNotExist(err) {
- return dir, err
- }
-+
-+ // Check if a .ziphash file exists. It should be created before the
-+ // zip is extracted, but if it was deleted (by another program?), we need
-+ // to re-calculate it.
-+ ziphashPath, err := CachePath(m, "ziphash")
-+ if err != nil {
-+ return dir, err
-+ }
-+ if _, err := os.Stat(ziphashPath); os.IsNotExist(err) {
-+ return dir, &DownloadDirPartialError{dir, errors.New("ziphash file is missing")}
-+ } else if err != nil {
-+ return dir, err
-+ }
- return dir, nil
- }
-
-diff --git a/src/cmd/go/internal/modfetch/fetch.go b/src/cmd/go/internal/modfetch/fetch.go
-index fd7a5cef83..6a6c972157 100644
---- a/src/cmd/go/internal/modfetch/fetch.go
-+++ b/src/cmd/go/internal/modfetch/fetch.go
-@@ -206,13 +206,16 @@ func DownloadZip(mod module.Version) (zipfile string, err error) {
- if err != nil {
- return cached{"", err}
- }
-+ ziphashfile := zipfile + "hash"
-
-- // Skip locking if the zipfile already exists.
-+ // Return without locking if the zip and ziphash files exist.
- if _, err := os.Stat(zipfile); err == nil {
-- return cached{zipfile, nil}
-+ if _, err := os.Stat(ziphashfile); err == nil {
-+ return cached{zipfile, nil}
-+ }
- }
-
-- // The zip file does not exist. Acquire the lock and create it.
-+ // The zip or ziphash file does not exist. Acquire the lock and create them.
- if cfg.CmdName != "mod download" {
- fmt.Fprintf(os.Stderr, "go: downloading %s %s\n", mod.Path, mod.Version)
- }
-@@ -222,14 +225,6 @@ func DownloadZip(mod module.Version) (zipfile string, err error) {
- }
- defer unlock()
-
-- // Double-check that the zipfile was not created while we were waiting for
-- // the lock.
-- if _, err := os.Stat(zipfile); err == nil {
-- return cached{zipfile, nil}
-- }
-- if err := os.MkdirAll(filepath.Dir(zipfile), 0777); err != nil {
-- return cached{"", err}
-- }
- if err := downloadZip(mod, zipfile); err != nil {
- return cached{"", err}
- }
-@@ -239,6 +234,25 @@ func DownloadZip(mod module.Version) (zipfile string, err error) {
- }
-
- func downloadZip(mod module.Version, zipfile string) (err error) {
-+ // Double-check that the zipfile was not created while we were waiting for
-+ // the lock in DownloadZip.
-+ ziphashfile := zipfile + "hash"
-+ var zipExists, ziphashExists bool
-+ if _, err := os.Stat(zipfile); err == nil {
-+ zipExists = true
-+ }
-+ if _, err := os.Stat(ziphashfile); err == nil {
-+ ziphashExists = true
-+ }
-+ if zipExists && ziphashExists {
-+ return nil
-+ }
-+
-+ // Create parent directories.
-+ if err := os.MkdirAll(filepath.Dir(zipfile), 0777); err != nil {
-+ return err
-+ }
-+
- // Clean up any remaining tempfiles from previous runs.
- // This is only safe to do because the lock file ensures that their
- // writers are no longer active.
-@@ -250,6 +264,12 @@ func downloadZip(mod module.Version, zipfile string) (err error) {
- }
- }
-
-+ // If the zip file exists, the ziphash file must have been deleted
-+ // or lost after a file system crash. Re-hash the zip without downloading.
-+ if zipExists {
-+ return hashZip(mod, zipfile, ziphashfile)
-+ }
-+
- // From here to the os.Rename call below is functionally almost equivalent to
- // renameio.WriteToFile, with one key difference: we want to validate the
- // contents of the file (by hashing it) before we commit it. Because the file
-@@ -306,15 +326,7 @@ func downloadZip(mod module.Version, zipfile string) (err error) {
- }
-
- // Hash the zip file and check the sum before renaming to the final location.
-- hash, err := dirhash.HashZip(f.Name(), dirhash.DefaultHash)
-- if err != nil {
-- return err
-- }
-- if err := checkModSum(mod, hash); err != nil {
-- return err
-- }
--
-- if err := renameio.WriteFile(zipfile+"hash", []byte(hash), 0666); err != nil {
-+ if err := hashZip(mod, f.Name(), ziphashfile); err != nil {
- return err
- }
- if err := os.Rename(f.Name(), zipfile); err != nil {
-@@ -326,6 +338,22 @@ func downloadZip(mod module.Version, zipfile string) (err error) {
- return nil
- }
-
-+// hashZip reads the zip file opened in f, then writes the hash to ziphashfile,
-+// overwriting that file if it exists.
-+//
-+// If the hash does not match go.sum (or the sumdb if enabled), hashZip returns
-+// an error and does not write ziphashfile.
-+func hashZip(mod module.Version, zipfile, ziphashfile string) error {
-+ hash, err := dirhash.HashZip(zipfile, dirhash.DefaultHash)
-+ if err != nil {
-+ return err
-+ }
-+ if err := checkModSum(mod, hash); err != nil {
-+ return err
-+ }
-+ return renameio.WriteFile(ziphashfile, []byte(hash), 0666)
-+}
-+
- // makeDirsReadOnly makes a best-effort attempt to remove write permissions for dir
- // and its transitive contents.
- func makeDirsReadOnly(dir string) {
-@@ -457,11 +485,6 @@ func readGoSum(dst map[module.Version][]string, file string, data []byte) error
-
- // checkMod checks the given module's checksum.
- func checkMod(mod module.Version) {
-- if cfg.GOMODCACHE == "" {
-- // Do not use current directory.
-- return
-- }
--
- // Do the file I/O before acquiring the go.sum lock.
- ziphash, err := CachePath(mod, "ziphash")
- if err != nil {
-@@ -469,10 +492,6 @@ func checkMod(mod module.Version) {
- }
- data, err := renameio.ReadFile(ziphash)
- if err != nil {
-- if errors.Is(err, os.ErrNotExist) {
-- // This can happen if someone does rm -rf GOPATH/src/cache/download. So it goes.
-- return
-- }
- base.Fatalf("verifying %v", module.VersionError(mod, err))
- }
- h := strings.TrimSpace(string(data))
-diff --git a/src/cmd/go/testdata/script/mod_get_missing_ziphash.txt b/src/cmd/go/testdata/script/mod_get_missing_ziphash.txt
-new file mode 100644
-index 0000000000..afb5d2e844
---- /dev/null
-+++ b/src/cmd/go/testdata/script/mod_get_missing_ziphash.txt
-@@ -0,0 +1,55 @@
-+# Test that if the module cache contains an extracted source directory but not
-+# a ziphash, 'go build' complains about a missing sum, and 'go get' adds
-+# the sum. Verifies #44749.
-+
-+# With a tidy go.sum, go build succeeds. This also populates the module cache.
-+cp go.sum.tidy go.sum
-+go build -n use
-+env GOPROXY=off
-+env GOSUMDB=off
-+
-+# Control case: if we delete the hash for rsc.io/quote v1.5.2,
-+# 'go build' reports an error. 'go get' adds the sum.
-+cp go.sum.bug go.sum
-+! go build -n -mod=readonly use
-+stderr '^go: updates to go.sum needed, disabled by -mod=readonly$'
-+go get -d use
-+cmp go.sum go.sum.tidy
-+go build -n use
-+
-+# If we delete the hash *and* the ziphash file, we should see the same behavior.
-+cp go.sum.bug go.sum
-+rm $WORK/gopath/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.ziphash
-+! go build -n -mod=readonly use
-+stderr '^go: updates to go.sum needed, disabled by -mod=readonly$'
-+go get -d use
-+cmp go.sum go.sum.tidy
-+go build -n use
-+
-+-- go.mod --
-+module use
-+
-+go 1.17
-+
-+require rsc.io/quote v1.5.2
-+-- go.sum.tidy --
-+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:pvCbr/wm8HzDD3fVywevekufpn6tCGPY3spdHeZJEsw=
-+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-+rsc.io/quote v1.5.2 h1:3fEykkD9k7lYzXqCYrwGAf7iNhbk4yCjHmKBN9td4L0=
-+rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
-+rsc.io/sampler v1.3.0 h1:HLGR/BgEtI3r0uymSP/nl2uPLsUnNJX8toRyhfpBTII=
-+rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
-+rsc.io/testonly v1.0.0 h1:K/VWHdO+Jv7woUXG0GzVNx1czBXUt3Ib1deaMn+xk64=
-+rsc.io/testonly v1.0.0/go.mod h1:OqmGbIFOcF+XrFReLOGZ6BhMM7uMBiQwZsyNmh74SzY=
-+-- go.sum.bug --
-+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:pvCbr/wm8HzDD3fVywevekufpn6tCGPY3spdHeZJEsw=
-+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-+rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
-+rsc.io/sampler v1.3.0 h1:HLGR/BgEtI3r0uymSP/nl2uPLsUnNJX8toRyhfpBTII=
-+rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
-+rsc.io/testonly v1.0.0 h1:K/VWHdO+Jv7woUXG0GzVNx1czBXUt3Ib1deaMn+xk64=
-+rsc.io/testonly v1.0.0/go.mod h1:OqmGbIFOcF+XrFReLOGZ6BhMM7uMBiQwZsyNmh74SzY=
-+-- use.go --
-+package use
-+
-+import _ "rsc.io/quote"
-diff --git a/src/cmd/go/testdata/script/mod_verify.txt b/src/cmd/go/testdata/script/mod_verify.txt
-index 646bc62bb7..7163d1a64b 100644
---- a/src/cmd/go/testdata/script/mod_verify.txt
-+++ b/src/cmd/go/testdata/script/mod_verify.txt
-@@ -50,10 +50,13 @@ go mod tidy
- grep '^rsc.io/quote v1.1.0/go.mod ' go.sum
- grep '^rsc.io/quote v1.1.0 ' go.sum
-
--# sync should ignore missing ziphash; verify should not
-+# verify should fail on a missing ziphash. tidy should restore it.
- rm $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.ziphash
--go mod tidy
- ! go mod verify
-+stderr '^rsc.io/quote v1.1.0: missing ziphash: open '$GOPATH'[/\\]pkg[/\\]mod[/\\]cache[/\\]download[/\\]rsc.io[/\\]quote[/\\]@v[/\\]v1.1.0.ziphash'
-+go mod tidy
-+exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.ziphash
-+go mod verify
-
- # Packages below module root should not be mentioned in go.sum.
- rm go.sum
---
-2.27.0
-
diff --git a/0026-release-branch.go1.15-cmd-link-generate-trampoline-f.patch b/0026-release-branch.go1.15-cmd-link-generate-trampoline-f.patch
deleted file mode 100644
index 5a6ef3e1bd21455e52c202c17cfe25b02076c724..0000000000000000000000000000000000000000
--- a/0026-release-branch.go1.15-cmd-link-generate-trampoline-f.patch
+++ /dev/null
@@ -1,133 +0,0 @@
-From 7c88ae4117c16c1e5b80189b81d67845e1c40d9d Mon Sep 17 00:00:00 2001
-From: Cherry Zhang
-Date: Tue, 16 Feb 2021 10:20:58 -0500
-Subject: [PATCH 26/44] [release-branch.go1.15] cmd/link: generate trampoline
- for inter-dependent packages
-
-Currently, in the trampoline generation pass we expect packages
-are laid out in dependency order, so a cross-package jump always
-has a known target address so we can check if a trampoline is
-needed. With linknames, there can be cycles in the package
-dependency graph, making this algorithm no longer work. For them,
-as the target address is unkown we conservatively generate a
-trampoline. This may generate unnecessary trampolines (if the
-packages turn out laid together), but package cycles are extremely
-rare so this is fine.
-
-Updates #44639.
-Fixes #44748.
-
-Change-Id: I2dc2998edacbda27d726fc79452313a21d07787a
-Reviewed-on: https://go-review.googlesource.com/c/go/+/292490
-Trust: Cherry Zhang
-Reviewed-by: Than McIntosh
-(cherry picked from commit 098504c73ff6ece19566a1ac811ceed73be7c81d)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/298030
-Run-TryBot: Cherry Zhang
-TryBot-Result: Go Bot
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/7c88ae4117c16c1e5b80189b81d67845e1c40d9d
-
----
- src/cmd/link/internal/arm/asm.go | 16 +++++++++++-----
- src/cmd/link/internal/ld/data.go | 12 +++++-------
- src/cmd/link/internal/ppc64/asm.go | 12 +++++++++---
- 3 files changed, 25 insertions(+), 15 deletions(-)
-
-diff --git a/src/cmd/link/internal/arm/asm.go b/src/cmd/link/internal/arm/asm.go
-index 903e62108e..43643341d2 100644
---- a/src/cmd/link/internal/arm/asm.go
-+++ b/src/cmd/link/internal/arm/asm.go
-@@ -373,10 +373,16 @@ func trampoline(ctxt *ld.Link, ldr *loader.Loader, ri int, rs, s loader.Sym) {
- r := relocs.At2(ri)
- switch r.Type() {
- case objabi.R_CALLARM:
-- // r.Add is the instruction
-- // low 24-bit encodes the target address
-- t := (ldr.SymValue(rs) + int64(signext24(r.Add()&0xffffff)*4) - (ldr.SymValue(s) + int64(r.Off()))) / 4
-- if t > 0x7fffff || t < -0x800000 || (*ld.FlagDebugTramp > 1 && ldr.SymPkg(s) != ldr.SymPkg(rs)) {
-+ var t int64
-+ // ldr.SymValue(rs) == 0 indicates a cross-package jump to a function that is not yet
-+ // laid out. Conservatively use a trampoline. This should be rare, as we lay out packages
-+ // in dependency order.
-+ if ldr.SymValue(rs) != 0 {
-+ // r.Add is the instruction
-+ // low 24-bit encodes the target address
-+ t = (ldr.SymValue(rs) + int64(signext24(r.Add()&0xffffff)*4) - (ldr.SymValue(s) + int64(r.Off()))) / 4
-+ }
-+ if t > 0x7fffff || t < -0x800000 || ldr.SymValue(rs) == 0 || (*ld.FlagDebugTramp > 1 && ldr.SymPkg(s) != ldr.SymPkg(rs)) {
- // direct call too far, need to insert trampoline.
- // look up existing trampolines first. if we found one within the range
- // of direct call, we can reuse it. otherwise create a new one.
-@@ -447,7 +453,7 @@ func gentramp(arch *sys.Arch, linkmode ld.LinkMode, ldr *loader.Loader, tramp *l
- arch.ByteOrder.PutUint32(P[8:], o3)
- tramp.SetData(P)
-
-- if linkmode == ld.LinkExternal {
-+ if linkmode == ld.LinkExternal || ldr.SymValue(target) == 0 {
- r := loader.Reloc{
- Off: 8,
- Type: objabi.R_ADDR,
-diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go
-index d3f308c8fa..2b55a5f6fc 100644
---- a/src/cmd/link/internal/ld/data.go
-+++ b/src/cmd/link/internal/ld/data.go
-@@ -105,14 +105,12 @@ func trampoline(ctxt *Link, s loader.Sym) {
- }
- rs = ldr.ResolveABIAlias(rs)
- if ldr.SymValue(rs) == 0 && (ldr.SymType(rs) != sym.SDYNIMPORT && ldr.SymType(rs) != sym.SUNDEFEXT) {
-- if ldr.SymPkg(rs) != ldr.SymPkg(s) {
-- if !isRuntimeDepPkg(ldr.SymPkg(s)) || !isRuntimeDepPkg(ldr.SymPkg(rs)) {
-- ctxt.Errorf(s, "unresolved inter-package jump to %s(%s) from %s", ldr.SymName(rs), ldr.SymPkg(rs), ldr.SymPkg(s))
-- }
-- // runtime and its dependent packages may call to each other.
-- // they are fine, as they will be laid down together.
-+ if ldr.SymPkg(rs) == ldr.SymPkg(s) {
-+ continue // symbols in the same package are laid out together
-+ }
-+ if isRuntimeDepPkg(ldr.SymPkg(s)) && isRuntimeDepPkg(ldr.SymPkg(rs)) {
-+ continue // runtime packages are laid out together
- }
-- continue
- }
-
- thearch.Trampoline(ctxt, ldr, ri, rs, s)
-diff --git a/src/cmd/link/internal/ppc64/asm.go b/src/cmd/link/internal/ppc64/asm.go
-index b1c0873d7a..a3ecd43f89 100644
---- a/src/cmd/link/internal/ppc64/asm.go
-+++ b/src/cmd/link/internal/ppc64/asm.go
-@@ -672,13 +672,19 @@ func trampoline(ctxt *ld.Link, ldr *loader.Loader, ri int, rs, s loader.Sym) {
-
- relocs := ldr.Relocs(s)
- r := relocs.At2(ri)
-- t := ldr.SymValue(rs) + r.Add() - (ldr.SymValue(s) + int64(r.Off()))
-+ var t int64
-+ // ldr.SymValue(rs) == 0 indicates a cross-package jump to a function that is not yet
-+ // laid out. Conservatively use a trampoline. This should be rare, as we lay out packages
-+ // in dependency order.
-+ if ldr.SymValue(rs) != 0 {
-+ t = ldr.SymValue(rs) + r.Add() - (ldr.SymValue(s) + int64(r.Off()))
-+ }
- switch r.Type() {
- case objabi.R_CALLPOWER:
-
- // If branch offset is too far then create a trampoline.
-
-- if (ctxt.IsExternal() && ldr.SymSect(s) != ldr.SymSect(rs)) || (ctxt.IsInternal() && int64(int32(t<<6)>>6) != t) || (*ld.FlagDebugTramp > 1 && ldr.SymPkg(s) != ldr.SymPkg(rs)) {
-+ if (ctxt.IsExternal() && ldr.SymSect(s) != ldr.SymSect(rs)) || (ctxt.IsInternal() && int64(int32(t<<6)>>6) != t) || ldr.SymValue(rs) == 0 || (*ld.FlagDebugTramp > 1 && ldr.SymPkg(s) != ldr.SymPkg(rs)) {
- var tramp loader.Sym
- for i := 0; ; i++ {
-
-@@ -769,7 +775,7 @@ func gentramp(ctxt *ld.Link, ldr *loader.Loader, tramp *loader.SymbolBuilder, ta
-
- // With external linking, the target address must be
- // relocated using LO and HA
-- if ctxt.IsExternal() {
-+ if ctxt.IsExternal() || ldr.SymValue(target) == 0 {
- r := loader.Reloc{
- Off: 0,
- Type: objabi.R_ADDRPOWER,
---
-2.27.0
-
diff --git a/0027-release-branch.go1.15-net-http-update-bundled-x-net-.patch b/0027-release-branch.go1.15-net-http-update-bundled-x-net-.patch
deleted file mode 100644
index a6196290d6d9d2208dd93a4a153e444521f788b7..0000000000000000000000000000000000000000
--- a/0027-release-branch.go1.15-net-http-update-bundled-x-net-.patch
+++ /dev/null
@@ -1,49 +0,0 @@
-From 69b943102868747ff2b62d9ada02c464d9984aef Mon Sep 17 00:00:00 2001
-From: Dmitri Shuralyov
-Date: Mon, 29 Mar 2021 11:19:23 -0400
-Subject: [PATCH 27/44] [release-branch.go1.15] net/http: update bundled
- x/net/http2
-
-Bring in the change in CL 304309 with:
-
- go mod edit -replace=golang.org/x/net=golang.org/x/net@release-branch.go1.15-bundle
- GOFLAGS='-mod=mod' go generate -run=bundle std
- go mod edit -dropreplace=golang.org/x/net
- go get -d golang.org/x/net@release-branch.go1.15
- go mod tidy
- go mod vendor
-
-For #45076.
-Updates #40213.
-
-Change-Id: I68d5e1f2394508c9cf8627fb852dd9e906d45016
-Reviewed-on: https://go-review.googlesource.com/c/go/+/305489
-Trust: Dmitri Shuralyov
-Trust: Emmanuel Odeke
-Run-TryBot: Dmitri Shuralyov
-Reviewed-by: Emmanuel Odeke
-TryBot-Result: Go Bot
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/69b943102868747ff2b62d9ada02c464d9984aef
-
----
- src/net/http/h2_bundle.go | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go
-index 678c6eb9d4..3d83084702 100644
---- a/src/net/http/h2_bundle.go
-+++ b/src/net/http/h2_bundle.go
-@@ -8985,6 +8985,8 @@ func http2strSliceContains(ss []string, s string) bool {
-
- type http2erringRoundTripper struct{ err error }
-
-+func (rt http2erringRoundTripper) RoundTripErr() error { return rt.err }
-+
- func (rt http2erringRoundTripper) RoundTrip(*Request) (*Response, error) { return nil, rt.err }
-
- // gzipReader wraps a response body so it can lazily
---
-2.27.0
-
diff --git a/0028-release-branch.go1.15-net-http-fix-detection-of-Roun.patch b/0028-release-branch.go1.15-net-http-fix-detection-of-Roun.patch
deleted file mode 100644
index ecd987ac95779268059a530e49ff52765ec4515f..0000000000000000000000000000000000000000
--- a/0028-release-branch.go1.15-net-http-fix-detection-of-Roun.patch
+++ /dev/null
@@ -1,81 +0,0 @@
-From be872812063f29e9c0d280fb37289d40330d96db Mon Sep 17 00:00:00 2001
-From: Michael Fraenkel
-Date: Thu, 16 Jul 2020 21:30:12 -0600
-Subject: [PATCH 28/44] [release-branch.go1.15] net/http: fix detection of
- Roundtrippers that always error
-
-CL 220905 added code to identify alternate transports that always error
-by using http2erringRoundTripper. This does not work when the transport
-is from another package, e.g., http2.erringRoundTripper.
-Expose a new method that allow detection of such a RoundTripper.
-Switch to an interface that is both a RoundTripper and can return the
-underlying error.
-
-Fixes #45076.
-Updates #40213.
-
-Change-Id: I170739857ab9e99dffb5fa55c99b24b23c2f9c54
-Reviewed-on: https://go-review.googlesource.com/c/go/+/243258
-Reviewed-by: Emmanuel Odeke
-Run-TryBot: Emmanuel Odeke
-TryBot-Result: Gobot Gobot
-Reviewed-on: https://go-review.googlesource.com/c/go/+/304210
-Trust: Dmitri Shuralyov
-Trust: Emmanuel Odeke
-Run-TryBot: Dmitri Shuralyov
-TryBot-Result: Go Bot
-Reviewed-by: Emmanuel Odeke
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/be872812063f29e9c0d280fb37289d40330d96db
-
----
- src/net/http/omithttp2.go | 4 ----
- src/net/http/transport.go | 8 ++++++--
- 2 files changed, 6 insertions(+), 6 deletions(-)
-
-diff --git a/src/net/http/omithttp2.go b/src/net/http/omithttp2.go
-index 7e2f492579..c8f5c28a59 100644
---- a/src/net/http/omithttp2.go
-+++ b/src/net/http/omithttp2.go
-@@ -32,10 +32,6 @@ type http2Transport struct {
- func (*http2Transport) RoundTrip(*Request) (*Response, error) { panic(noHTTP2) }
- func (*http2Transport) CloseIdleConnections() {}
-
--type http2erringRoundTripper struct{ err error }
--
--func (http2erringRoundTripper) RoundTrip(*Request) (*Response, error) { panic(noHTTP2) }
--
- type http2noDialH2RoundTripper struct{}
-
- func (http2noDialH2RoundTripper) RoundTrip(*Request) (*Response, error) { panic(noHTTP2) }
-diff --git a/src/net/http/transport.go b/src/net/http/transport.go
-index 6e430b9885..88d15a5919 100644
---- a/src/net/http/transport.go
-+++ b/src/net/http/transport.go
-@@ -1531,6 +1531,10 @@ func (pconn *persistConn) addTLS(name string, trace *httptrace.ClientTrace) erro
- return nil
- }
-
-+type erringRoundTripper interface {
-+ RoundTripErr() error
-+}
-+
- func (t *Transport) dialConn(ctx context.Context, cm connectMethod) (pconn *persistConn, err error) {
- pconn = &persistConn{
- t: t,
-@@ -1697,9 +1701,9 @@ func (t *Transport) dialConn(ctx context.Context, cm connectMethod) (pconn *pers
- if s := pconn.tlsState; s != nil && s.NegotiatedProtocolIsMutual && s.NegotiatedProtocol != "" {
- if next, ok := t.TLSNextProto[s.NegotiatedProtocol]; ok {
- alt := next(cm.targetAddr, pconn.conn.(*tls.Conn))
-- if e, ok := alt.(http2erringRoundTripper); ok {
-+ if e, ok := alt.(erringRoundTripper); ok {
- // pconn.conn was closed by next (http2configureTransport.upgradeFn).
-- return nil, e.err
-+ return nil, e.RoundTripErr()
- }
- return &persistConn{t: t, cacheKey: pconn.cacheKey, alt: alt}, nil
- }
---
-2.27.0
-
diff --git a/0029-release-branch.go1.15-build-set-GOPATH-consistently-.patch b/0029-release-branch.go1.15-build-set-GOPATH-consistently-.patch
deleted file mode 100644
index a0a7d65710220c71eebe65c149e9d0bc7e842679..0000000000000000000000000000000000000000
--- a/0029-release-branch.go1.15-build-set-GOPATH-consistently-.patch
+++ /dev/null
@@ -1,105 +0,0 @@
-From 6df5d3a581380a85183c591d1fd9063a5e8e4b23 Mon Sep 17 00:00:00 2001
-From: Russ Cox
-Date: Tue, 26 Jan 2021 21:14:43 -0500
-Subject: [PATCH 29/44] [release-branch.go1.15] build: set GOPATH consistently
- in run.bash, run.bat, run.rc
-
-We used to clear GOPATH in all the build scripts.
-Clearing GOPATH is misleading at best, since you just end up
-with the default GOPATH (%USERPROFILE%\go on Windows).
-Unless that's your GOROOT, in which case you end up with a
-fatal error from the go command (#43938).
-
-run.bash changed to setting GOPATH=/dev/null, which has no
-clear analogue on Windows.
-
-run.rc still clears GOPATH.
-
-Change them all to set GOPATH to a non-existent directory
-/nonexist-gopath or c:\nonexist-gopath.
-
-For #45238.
-Fixes #45239.
-
-Change-Id: I51edd66d37ff6a891b0d0541d91ecba97fbbb03d
-Reviewed-on: https://go-review.googlesource.com/c/go/+/288818
-Trust: Russ Cox
-Trust: Jason A. Donenfeld
-Reviewed-by: Cherry Zhang
-Reviewed-by: Alex Brainman
-Reviewed-by: Jason A. Donenfeld
-(cherry picked from commit bb6efb96092cc8ae398c29e3b052a0051c746f88)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/304773
-Run-TryBot: Dmitri Shuralyov
-TryBot-Result: Go Bot
-Reviewed-by: Alexander Rakoczy
-Reviewed-by: Carlos Amedee
-Trust: Carlos Amedee
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/6df5d3a581380a85183c591d1fd9063a5e8e4b23
-
----
- src/run.bash | 10 +---------
- src/run.bat | 4 +---
- src/run.rc | 9 ++++-----
- 3 files changed, 6 insertions(+), 17 deletions(-)
-
-diff --git a/src/run.bash b/src/run.bash
-index 706b4b60ee..2123c509f8 100755
---- a/src/run.bash
-+++ b/src/run.bash
-@@ -23,15 +23,7 @@ fi
-
- eval $(../bin/go env)
- export GOROOT # The api test requires GOROOT to be set, so set it to match ../bin/go.
--
--# We disallow local import for non-local packages, if $GOROOT happens
--# to be under $GOPATH, then some tests below will fail. $GOPATH needs
--# to be set to a non-empty string, else Go will set a default value
--# that may also conflict with $GOROOT. The $GOPATH value doesn't need
--# to point to an actual directory, it just needs to pass the semantic
--# checks performed by Go. Use $GOROOT to define $GOPATH so that we
--# don't blunder into a user-defined symbolic link.
--export GOPATH=/dev/null
-+export GOPATH=/nonexist-gopath
-
- unset CDPATH # in case user has it set
- export GOBIN=$GOROOT/bin # Issue 14340
-diff --git a/src/run.bat b/src/run.bat
-index c299671c13..edcaf52659 100644
---- a/src/run.bat
-+++ b/src/run.bat
-@@ -18,9 +18,7 @@ setlocal
-
- set GOBUILDFAIL=0
-
--:: we disallow local import for non-local packages, if %GOROOT% happens
--:: to be under %GOPATH%, then some tests below will fail
--set GOPATH=
-+set GOPATH=c:\nonexist-gopath
- :: Issue 14340: ignore GOBIN during all.bat.
- set GOBIN=
- set GOFLAGS=
-diff --git a/src/run.rc b/src/run.rc
-index ab7abfa991..a7b4801207 100755
---- a/src/run.rc
-+++ b/src/run.rc
-@@ -12,10 +12,9 @@ if(! test -f ../bin/go){
-
- eval `{../bin/go env}
-
--GOPATH = () # we disallow local import for non-local packages, if $GOROOT happens
-- # to be under $GOPATH, then some tests below will fail
--GOBIN = () # Issue 14340
--GOFLAGS = ()
--GO111MODULE = ()
-+GOPATH=/nonexist-gopath
-+GOBIN=() # Issue 14340
-+GOFLAGS=()
-+GO111MODULE=()
-
- exec ../bin/go tool dist test -rebuild $*
---
-2.27.0
-
diff --git a/0030-release-branch.go1.15-database-sql-fix-tx-stmt-deadl.patch b/0030-release-branch.go1.15-database-sql-fix-tx-stmt-deadl.patch
deleted file mode 100644
index 4d1c4ea520131417e0afae93f0555b402414ef8b..0000000000000000000000000000000000000000
--- a/0030-release-branch.go1.15-database-sql-fix-tx-stmt-deadl.patch
+++ /dev/null
@@ -1,134 +0,0 @@
-From c77418f4cac41c42566ca90921a1f928995cfba2 Mon Sep 17 00:00:00 2001
-From: Emmanuel T Odeke
-Date: Mon, 18 Jan 2021 16:18:11 -0800
-Subject: [PATCH 30/44] [release-branch.go1.15] database/sql: fix tx stmt
- deadlock when rollback
-
-Tx acquires tx.closemu W-lock and then acquires stmt.closemu.W-lock
-to fully close the transaction and associated prepared statement.
-Stmt query and execution run in reverse ways - acquires
-stmt.closemu.R-lock and then acquires tx.closemu.R-lock to grab tx
-connection, which may cause deadlock.
-
-Prevent the lock is held around tx.closePrepared to ensure no
-deadlock happens.
-
-Includes a test fix from CL 266097.
-Fixes #42884
-Updates #40985
-Updates #42259
-
-Change-Id: Id52737660ada3cebdfff6efc23366cdc3224b8e8
-Reviewed-on: https://go-review.googlesource.com/c/go/+/250178
-Run-TryBot: Emmanuel Odeke
-TryBot-Result: Go Bot
-Reviewed-by: Daniel Theophanes
-Trust: Emmanuel Odeke
-(cherry picked from commit d4c1ad882973e407ff85b977f4ce5b9435451190)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/284513
-Reviewed-by: Dmitri Shuralyov
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/c77418f4cac41c42566ca90921a1f928995cfba2
-
----
- src/database/sql/sql.go | 14 +++++++-------
- src/database/sql/sql_test.go | 28 ++++++++++++++++++++++++++++
- 2 files changed, 35 insertions(+), 7 deletions(-)
-
-diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go
-index b3d0653f5c..3d1367d28f 100644
---- a/src/database/sql/sql.go
-+++ b/src/database/sql/sql.go
-@@ -2080,10 +2080,10 @@ func (tx *Tx) isDone() bool {
- // that has already been committed or rolled back.
- var ErrTxDone = errors.New("sql: transaction has already been committed or rolled back")
-
--// closeLocked returns the connection to the pool and
-+// close returns the connection to the pool and
- // must only be called by Tx.rollback or Tx.Commit while
--// closemu is Locked and tx already canceled.
--func (tx *Tx) closeLocked(err error) {
-+// tx is already canceled and won't be executed concurrently.
-+func (tx *Tx) close(err error) {
- tx.releaseConn(err)
- tx.dc = nil
- tx.txi = nil
-@@ -2157,7 +2157,7 @@ func (tx *Tx) Commit() error {
- // to ensure no other connection has an active query.
- tx.cancel()
- tx.closemu.Lock()
-- defer tx.closemu.Unlock()
-+ tx.closemu.Unlock()
-
- var err error
- withLock(tx.dc, func() {
-@@ -2166,7 +2166,7 @@ func (tx *Tx) Commit() error {
- if err != driver.ErrBadConn {
- tx.closePrepared()
- }
-- tx.closeLocked(err)
-+ tx.close(err)
- return err
- }
-
-@@ -2189,7 +2189,7 @@ func (tx *Tx) rollback(discardConn bool) error {
- // to ensure no other connection has an active query.
- tx.cancel()
- tx.closemu.Lock()
-- defer tx.closemu.Unlock()
-+ tx.closemu.Unlock()
-
- var err error
- withLock(tx.dc, func() {
-@@ -2201,7 +2201,7 @@ func (tx *Tx) rollback(discardConn bool) error {
- if discardConn {
- err = driver.ErrBadConn
- }
-- tx.closeLocked(err)
-+ tx.close(err)
- return err
- }
-
-diff --git a/src/database/sql/sql_test.go b/src/database/sql/sql_test.go
-index 5727f0d8aa..d7d4642608 100644
---- a/src/database/sql/sql_test.go
-+++ b/src/database/sql/sql_test.go
-@@ -2810,6 +2810,34 @@ func TestTxCannotCommitAfterRollback(t *testing.T) {
- }
- }
-
-+// Issue 40985 transaction statement deadlock while context cancel.
-+func TestTxStmtDeadlock(t *testing.T) {
-+ db := newTestDB(t, "people")
-+ defer closeDB(t, db)
-+
-+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Millisecond)
-+ defer cancel()
-+ tx, err := db.BeginTx(ctx, nil)
-+ if err != nil {
-+ t.Fatal(err)
-+ }
-+
-+ stmt, err := tx.Prepare("SELECT|people|name,age|age=?")
-+ if err != nil {
-+ t.Fatal(err)
-+ }
-+ // Run number of stmt queries to reproduce deadlock from context cancel
-+ for i := 0; i < 1e3; i++ {
-+ // Encounter any close related errors (e.g.. ErrTxDone, stmt is closed)
-+ // is expected due to context cancel.
-+ _, err = stmt.Query(1)
-+ if err != nil {
-+ break
-+ }
-+ }
-+ _ = tx.Rollback()
-+}
-+
- // Issue32530 encounters an issue where a connection may
- // expire right after it comes out of a used connection pool
- // even when a new connection is requested.
---
-2.27.0
-
diff --git a/0031-release-branch.go1.15-cmd-compile-disable-shortcircu.patch b/0031-release-branch.go1.15-cmd-compile-disable-shortcircu.patch
deleted file mode 100644
index fda0c965c47f0ec413492e77fe6c0d5844a44535..0000000000000000000000000000000000000000
--- a/0031-release-branch.go1.15-cmd-compile-disable-shortcircu.patch
+++ /dev/null
@@ -1,107 +0,0 @@
-From f17b659d0a9a43235f67c155b08023124b3fc35b Mon Sep 17 00:00:00 2001
-From: Keith Randall
-Date: Tue, 23 Mar 2021 14:48:47 -0700
-Subject: [PATCH 31/44] [release-branch.go1.15] cmd/compile: disable
- shortcircuit optimization for intertwined phi values
-
-We need to be careful that when doing value graph surgery, we not
-re-substitute a value that has already been substituted. That can lead
-to confusing a previous iteration's value with the current iteration's
-value.
-
-The simple fix in this CL just aborts the optimization if it detects
-intertwined phis (a phi which is the argument to another phi). It
-might be possible to keep the optimization with a more complicated
-CL, but:
- 1) This CL is clearly safe to backport.
- 2) There were no instances of this abort triggering in
- all.bash, prior to the test introduced in this CL.
-
-Fixes #45187
-
-Change-Id: I2411dca03948653c053291f6829a76bec0c32330
-Reviewed-on: https://go-review.googlesource.com/c/go/+/304251
-Trust: Keith Randall
-Trust: Josh Bleecher Snyder
-Run-TryBot: Keith Randall
-TryBot-Result: Go Bot
-Reviewed-by: Josh Bleecher Snyder
-(cherry picked from commit 771c57e68ed5ef2bbb0eafc0d48419f59d143932)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/304529
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/f17b659d0a9a43235f67c155b08023124b3fc35b
-
----
- src/cmd/compile/internal/ssa/shortcircuit.go | 18 ++++++++++++
- test/fixedbugs/issue45175.go | 29 ++++++++++++++++++++
- 2 files changed, 47 insertions(+)
- create mode 100644 test/fixedbugs/issue45175.go
-
-diff --git a/src/cmd/compile/internal/ssa/shortcircuit.go b/src/cmd/compile/internal/ssa/shortcircuit.go
-index c5df457c4e..9cf29fe413 100644
---- a/src/cmd/compile/internal/ssa/shortcircuit.go
-+++ b/src/cmd/compile/internal/ssa/shortcircuit.go
-@@ -138,6 +138,24 @@ func shortcircuitBlock(b *Block) bool {
- if len(b.Values) != nval+nOtherPhi {
- return false
- }
-+ if nOtherPhi > 0 {
-+ // Check for any phi which is the argument of another phi.
-+ // These cases are tricky, as substitutions done by replaceUses
-+ // are no longer trivial to do in any ordering. See issue 45175.
-+ m := make(map[*Value]bool, 1+nOtherPhi)
-+ for _, v := range b.Values {
-+ if v.Op == OpPhi {
-+ m[v] = true
-+ }
-+ }
-+ for v := range m {
-+ for _, a := range v.Args {
-+ if a != v && m[a] {
-+ return false
-+ }
-+ }
-+ }
-+ }
-
- // Locate index of first const phi arg.
- cidx := -1
-diff --git a/test/fixedbugs/issue45175.go b/test/fixedbugs/issue45175.go
-new file mode 100644
-index 0000000000..02dfe8a0a9
---- /dev/null
-+++ b/test/fixedbugs/issue45175.go
-@@ -0,0 +1,29 @@
-+// run
-+
-+// Copyright 2021 The Go Authors. All rights reserved.
-+// Use of this source code is governed by a BSD-style
-+// license that can be found in the LICENSE file.
-+
-+package main
-+
-+//go:noinline
-+func f(c bool) int {
-+ b := true
-+ x := 0
-+ y := 1
-+ for b {
-+ b = false
-+ y = x
-+ x = 2
-+ if c {
-+ return 3
-+ }
-+ }
-+ return y
-+}
-+
-+func main() {
-+ if got := f(false); got != 0 {
-+ panic(got)
-+ }
-+}
---
-2.27.0
-
diff --git a/0032-release-branch.go1.15-runtime-non-strict-InlTreeInde.patch b/0032-release-branch.go1.15-runtime-non-strict-InlTreeInde.patch
deleted file mode 100644
index 58ee86968d78f89cde41cd25d32a8f0c209f278a..0000000000000000000000000000000000000000
--- a/0032-release-branch.go1.15-runtime-non-strict-InlTreeInde.patch
+++ /dev/null
@@ -1,157 +0,0 @@
-From a07f9d2f82598d2f5cc0df0e813a6a2309cb96e6 Mon Sep 17 00:00:00 2001
-From: Michael Pratt
-Date: Thu, 11 Mar 2021 12:28:45 -0500
-Subject: [PATCH 32/44] [release-branch.go1.15] runtime: non-strict
- InlTreeIndex lookup in Frames.Next
-
-When using cgo, some of the frames can be provided by cgoTraceback, a
-cgo-provided function to generate C tracebacks. Unlike Go tracebacks,
-cgoTraceback has no particular guarantees that it produces valid
-tracebacks.
-
-If one of the (invalid) frames happens to put the PC in the alignment
-region at the end of a function (filled with int 3's on amd64), then
-Frames.Next will find a valid funcInfo for the PC, but pcdatavalue will
-panic because PCDATA doesn't cover this PC.
-
-Tolerate this case by doing a non-strict PCDATA lookup. We'll still show
-a bogus frame, but at least avoid throwing.
-
-For #44971
-Fixes #45302
-
-Change-Id: I9eed728470d6f264179a7615bd19845c941db78c
-Reviewed-on: https://go-review.googlesource.com/c/go/+/301369
-Trust: Michael Pratt
-Run-TryBot: Michael Pratt
-TryBot-Result: Go Bot
-Reviewed-by: Cherry Zhang
-(cherry picked from commit e4a4161f1f3157550846e1b6bd4fe83aae15778e)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/305890
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/a07f9d2f82598d2f5cc0df0e813a6a2309cb96e6
-
----
- src/runtime/symtab.go | 4 +-
- src/runtime/symtab_test.go | 85 ++++++++++++++++++++++++++++++++++++++
- 2 files changed, 88 insertions(+), 1 deletion(-)
-
-diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go
-index 1e86662adc..c77d513e74 100644
---- a/src/runtime/symtab.go
-+++ b/src/runtime/symtab.go
-@@ -102,7 +102,9 @@ func (ci *Frames) Next() (frame Frame, more bool) {
- name := funcname(funcInfo)
- if inldata := funcdata(funcInfo, _FUNCDATA_InlTree); inldata != nil {
- inltree := (*[1 << 20]inlinedCall)(inldata)
-- ix := pcdatavalue(funcInfo, _PCDATA_InlTreeIndex, pc, nil)
-+ // Non-strict as cgoTraceback may have added bogus PCs
-+ // with a valid funcInfo but invalid PCDATA.
-+ ix := pcdatavalue1(funcInfo, _PCDATA_InlTreeIndex, pc, nil, false)
- if ix >= 0 {
- // Note: entry is not modified. It always refers to a real frame, not an inlined one.
- f = nil
-diff --git a/src/runtime/symtab_test.go b/src/runtime/symtab_test.go
-index 01e5002659..ffa07c7f3a 100644
---- a/src/runtime/symtab_test.go
-+++ b/src/runtime/symtab_test.go
-@@ -8,6 +8,7 @@ import (
- "runtime"
- "strings"
- "testing"
-+ "unsafe"
- )
-
- func TestCaller(t *testing.T) {
-@@ -165,3 +166,87 @@ func TestNilName(t *testing.T) {
- t.Errorf("Name() = %q, want %q", got, "")
- }
- }
-+
-+var dummy int
-+
-+func inlined() {
-+ // Side effect to prevent elimination of this entire function.
-+ dummy = 42
-+}
-+
-+// A function with an InlTree. Returns a PC within the function body.
-+//
-+// No inline to ensure this complete function appears in output.
-+//
-+//go:noinline
-+func tracebackFunc(t *testing.T) uintptr {
-+ // This body must be more complex than a single call to inlined to get
-+ // an inline tree.
-+ inlined()
-+ inlined()
-+
-+ // Acquire a PC in this function.
-+ pc, _, _, ok := runtime.Caller(0)
-+ if !ok {
-+ t.Fatalf("Caller(0) got ok false, want true")
-+ }
-+
-+ return pc
-+}
-+
-+// Test that CallersFrames handles PCs in the alignment region between
-+// functions (int 3 on amd64) without crashing.
-+//
-+// Go will never generate a stack trace containing such an address, as it is
-+// not a valid call site. However, the cgo traceback function passed to
-+// runtime.SetCgoTraceback may not be completely accurate and may incorrect
-+// provide PCs in Go code or the alignement region between functions.
-+//
-+// Go obviously doesn't easily expose the problematic PCs to running programs,
-+// so this test is a bit fragile. Some details:
-+//
-+// * tracebackFunc is our target function. We want to get a PC in the
-+// alignment region following this function. This function also has other
-+// functions inlined into it to ensure it has an InlTree (this was the source
-+// of the bug in issue 44971).
-+//
-+// * We acquire a PC in tracebackFunc, walking forwards until FuncForPC says
-+// we're in a new function. The last PC of the function according to FuncForPC
-+// should be in the alignment region (assuming the function isn't already
-+// perfectly aligned).
-+//
-+// This is a regression test for issue 44971.
-+func TestFunctionAlignmentTraceback(t *testing.T) {
-+ pc := tracebackFunc(t)
-+
-+ // Double-check we got the right PC.
-+ f := runtime.FuncForPC(pc)
-+ if !strings.HasSuffix(f.Name(), "tracebackFunc") {
-+ t.Fatalf("Caller(0) = %+v, want tracebackFunc", f)
-+ }
-+
-+ // Iterate forward until we find a different function. Back up one
-+ // instruction is (hopefully) an alignment instruction.
-+ for runtime.FuncForPC(pc) == f {
-+ pc++
-+ }
-+ pc--
-+
-+ // Is this an alignment region filler instruction? We only check this
-+ // on amd64 for simplicity. If this function has no filler, then we may
-+ // get a false negative, but will never get a false positive.
-+ if runtime.GOARCH == "amd64" {
-+ code := *(*uint8)(unsafe.Pointer(pc))
-+ if code != 0xcc { // INT $3
-+ t.Errorf("PC %v code got %#x want 0xcc", pc, code)
-+ }
-+ }
-+
-+ // Finally ensure that Frames.Next doesn't crash when processing this
-+ // PC.
-+ frames := runtime.CallersFrames([]uintptr{pc})
-+ frame, _ := frames.Next()
-+ if frame.Func != f {
-+ t.Errorf("frames.Next() got %+v want %+v", frame.Func, f)
-+ }
-+}
---
-2.27.0
-
diff --git a/0033-release-branch.go1.15-cmd-cgo-avoid-exporting-all-sy.patch b/0033-release-branch.go1.15-cmd-cgo-avoid-exporting-all-sy.patch
deleted file mode 100644
index 39bc904fedfa8ff11eefd382c235f5f4e87ba7fe..0000000000000000000000000000000000000000
--- a/0033-release-branch.go1.15-cmd-cgo-avoid-exporting-all-sy.patch
+++ /dev/null
@@ -1,172 +0,0 @@
-From 5055314a5749664ab66a24beed8158552e276959 Mon Sep 17 00:00:00 2001
-From: Quim Muntal
-Date: Thu, 15 Oct 2020 23:12:49 +0200
-Subject: [PATCH 33/44] [release-branch.go1.15] cmd/cgo: avoid exporting all
- symbols on windows buildmode=c-shared
-
-Disable default symbol auto-export behaviour by marking exported
-function with the __declspec(dllexport) attribute. Old behaviour can
-still be used by setting -extldflags=-Wl,--export-all-symbols.
-
-See https://sourceware.org/binutils/docs/ld/WIN32.html for more info.
-
-This change cuts 50kb of a "hello world" dll.
-
-Updates #6853.
-Updates #30674.
-Fixes #43591.
-
-Change-Id: I9c7fb09c677cc760f24d0f7d199740ae73981413
-Reviewed-on: https://go-review.googlesource.com/c/go/+/262797
-Run-TryBot: Ian Lance Taylor
-TryBot-Result: Go Bot
-Reviewed-by: Ian Lance Taylor
-Reviewed-by: Alex Brainman
-Trust: Alex Brainman
-Reviewed-on: https://go-review.googlesource.com/c/go/+/300693
-Trust: Dmitri Shuralyov
-Run-TryBot: Dmitri Shuralyov
-Reviewed-by: David Chase
-
-Conflict:NA
-Reference:https://github.com/golang/go/commit/5055314a5749664ab66a24beed8158552e276959
-
----
- misc/cgo/testcshared/cshared_test.go | 96 ++++++++++++++++++++++++++++
- src/cmd/cgo/out.go | 6 +-
- 2 files changed, 101 insertions(+), 1 deletion(-)
-
-diff --git a/misc/cgo/testcshared/cshared_test.go b/misc/cgo/testcshared/cshared_test.go
-index bd4d341820..d717b4dfb3 100644
---- a/misc/cgo/testcshared/cshared_test.go
-+++ b/misc/cgo/testcshared/cshared_test.go
-@@ -7,6 +7,8 @@ package cshared_test
- import (
- "bytes"
- "debug/elf"
-+ "debug/pe"
-+ "encoding/binary"
- "flag"
- "fmt"
- "io/ioutil"
-@@ -355,6 +357,100 @@ func TestExportedSymbols(t *testing.T) {
- }
- }
-
-+func checkNumberOfExportedFunctionsWindows(t *testing.T, exportAllSymbols bool) {
-+ const prog = `
-+package main
-+
-+import "C"
-+
-+//export GoFunc
-+func GoFunc() {
-+ println(42)
-+}
-+
-+//export GoFunc2
-+func GoFunc2() {
-+ println(24)
-+}
-+
-+func main() {
-+}
-+`
-+
-+ tmpdir := t.TempDir()
-+
-+ srcfile := filepath.Join(tmpdir, "test.go")
-+ objfile := filepath.Join(tmpdir, "test.dll")
-+ if err := ioutil.WriteFile(srcfile, []byte(prog), 0666); err != nil {
-+ t.Fatal(err)
-+ }
-+ argv := []string{"build", "-buildmode=c-shared"}
-+ if exportAllSymbols {
-+ argv = append(argv, "-ldflags", "-extldflags=-Wl,--export-all-symbols")
-+ }
-+ argv = append(argv, "-o", objfile, srcfile)
-+ out, err := exec.Command("go", argv...).CombinedOutput()
-+ if err != nil {
-+ t.Fatalf("build failure: %s\n%s\n", err, string(out))
-+ }
-+
-+ f, err := pe.Open(objfile)
-+ if err != nil {
-+ t.Fatalf("pe.Open failed: %v", err)
-+ }
-+ defer f.Close()
-+ section := f.Section(".edata")
-+ if section == nil {
-+ t.Error(".edata section is not present")
-+ }
-+
-+ // TODO: deduplicate this struct from cmd/link/internal/ld/pe.go
-+ type IMAGE_EXPORT_DIRECTORY struct {
-+ _ [2]uint32
-+ _ [2]uint16
-+ _ [2]uint32
-+ NumberOfFunctions uint32
-+ NumberOfNames uint32
-+ _ [3]uint32
-+ }
-+ var e IMAGE_EXPORT_DIRECTORY
-+ if err := binary.Read(section.Open(), binary.LittleEndian, &e); err != nil {
-+ t.Fatalf("binary.Read failed: %v", err)
-+ }
-+
-+ expectedNumber := uint32(2)
-+
-+ if exportAllSymbols {
-+ if e.NumberOfFunctions <= expectedNumber {
-+ t.Fatalf("missing exported functions: %v", e.NumberOfFunctions)
-+ }
-+ if e.NumberOfNames <= expectedNumber {
-+ t.Fatalf("missing exported names: %v", e.NumberOfNames)
-+ }
-+ } else {
-+ if e.NumberOfFunctions != expectedNumber {
-+ t.Fatalf("too many exported functions: %v", e.NumberOfFunctions)
-+ }
-+ if e.NumberOfNames != expectedNumber {
-+ t.Fatalf("too many exported names: %v", e.NumberOfNames)
-+ }
-+ }
-+}
-+
-+func TestNumberOfExportedFunctions(t *testing.T) {
-+ if GOOS != "windows" {
-+ t.Skip("skipping windows only test")
-+ }
-+ t.Parallel()
-+
-+ t.Run("OnlyExported", func(t *testing.T) {
-+ checkNumberOfExportedFunctionsWindows(t, false)
-+ })
-+ t.Run("All", func(t *testing.T) {
-+ checkNumberOfExportedFunctionsWindows(t, true)
-+ })
-+}
-+
- // test1: shared library can be dynamically loaded and exported symbols are accessible.
- func TestExportedSymbolsWithDynamicLoad(t *testing.T) {
- t.Parallel()
-diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go
-index b9043efbf7..ee1c563495 100644
---- a/src/cmd/cgo/out.go
-+++ b/src/cmd/cgo/out.go
-@@ -961,7 +961,11 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) {
- }
-
- // Build the wrapper function compiled by gcc.
-- s := fmt.Sprintf("%s %s(", gccResult, exp.ExpName)
-+ gccExport := ""
-+ if goos == "windows" {
-+ gccExport = "__declspec(dllexport)"
-+ }
-+ s := fmt.Sprintf("%s %s %s(", gccExport, gccResult, exp.ExpName)
- if fn.Recv != nil {
- s += p.cgoType(fn.Recv.List[0].Type).C.String()
- s += " recv"
---
-2.27.0
-
diff --git a/0034-release-branch.go1.15-cmd-link-avoid-exporting-all-s.patch b/0034-release-branch.go1.15-cmd-link-avoid-exporting-all-s.patch
deleted file mode 100644
index 123220ef79d8250938a12add5530ab6dbca9bb8f..0000000000000000000000000000000000000000
--- a/0034-release-branch.go1.15-cmd-link-avoid-exporting-all-s.patch
+++ /dev/null
@@ -1,188 +0,0 @@
-From 82f9c6cac1bcc6bc80f17d1415ac3f62c0afa6c5 Mon Sep 17 00:00:00 2001
-From: Quim Muntal
-Date: Thu, 22 Oct 2020 22:32:20 +0200
-Subject: [PATCH 34/44] [release-branch.go1.15] cmd/link: avoid exporting all
- symbols on windows buildmode=pie
-
-Marking one functions with __declspec(dllexport) forces mingw to
-create .reloc section without having to export all symbols.
-
-See https://insights.sei.cmu.edu/cert/2018/08/when-aslr-is-not-really-aslr---the-case-of-incorrect-assumptions-and-bad-defaults.html for more info.
-
-This change cuts 73kb of a "hello world" pie binary.
-
-Updates #6853.
-Updates #40795.
-Fixes #43592.
-
-Change-Id: I3cc57c3b64f61187550bc8751dfa085f106c8475
-Reviewed-on: https://go-review.googlesource.com/c/go/+/264459
-Trust: Alex Brainman
-Run-TryBot: Alex Brainman
-TryBot-Result: Go Bot