libgo: update to go1.17.1 release

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/350414
This commit is contained in:
Ian Lance Taylor 2021-09-16 16:09:35 -07:00
parent 745781d24c
commit 54866f7a81
14 changed files with 154 additions and 21 deletions

View file

@ -1,4 +1,4 @@
c11d9f8275f2bbe9b05cdd815c79ac331f78e15c
850235e4b974b9c5c2d7a1f9860583bd07f2a45c
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.

View file

@ -1,4 +1,4 @@
ec5170397c724a8ae440b2bc529f857c86f0e6b1
21a4e67ad58e3c4a7c5254f60cda5be5c3c450ff
The first line of this file holds the git revision number of the
last merge done from the master library sources.

View file

@ -1 +1 @@
go1.17
go1.17.1

View file

@ -102,7 +102,7 @@ func (z *Reader) init(r io.ReaderAt, size int64) error {
// indicate it contains up to 1 << 128 - 1 files. Since each file has a
// header which will be _at least_ 30 bytes we can safely preallocate
// if (data size / 30) >= end.directoryRecords.
if (uint64(size)-end.directorySize)/30 >= end.directoryRecords {
if end.directorySize < uint64(size) && (uint64(size)-end.directorySize)/30 >= end.directoryRecords {
z.File = make([]*File, 0, end.directoryRecords)
}
z.Comment = end.comment

View file

@ -1384,3 +1384,21 @@ func TestCVE202133196(t *testing.T) {
t.Errorf("Archive has unexpected number of files, got %d, want 5", len(r.File))
}
}
func TestCVE202139293(t *testing.T) {
// directory size is so large, that the check in Reader.init
// overflows when subtracting from the archive size, causing
// the pre-allocation check to be bypassed.
data := []byte{
0x50, 0x4b, 0x06, 0x06, 0x05, 0x06, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x4b,
0x06, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x4b,
0x06, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
0xff, 0x50, 0xfe, 0x00, 0xff, 0x00, 0x3a, 0x00, 0x00, 0x00, 0xff,
}
_, err := NewReader(bytes.NewReader(data), int64(len(data)))
if err != ErrFormat {
t.Fatalf("unexpected error, got: %v, want: %v", err, ErrFormat)
}
}

View file

@ -190,8 +190,8 @@ func limiterForEdit(ctx context.Context, rs *Requirements, tryUpgrade, mustSelec
// raiseLimitsForUpgrades increases the module versions in maxVersions to the
// versions that would be needed to allow each of the modules in tryUpgrade
// (individually) and all of the modules in mustSelect (simultaneously) to be
// added as roots.
// (individually or in any combination) and all of the modules in mustSelect
// (simultaneously) to be added as roots.
//
// Versions not present in maxVersion are unrestricted, and it is assumed that
// they will not be promoted to root requirements (and thus will not contribute
@ -213,18 +213,42 @@ func raiseLimitsForUpgrades(ctx context.Context, maxVersion map[string]string, d
}
}
var eagerUpgrades []module.Version
var (
eagerUpgrades []module.Version
isLazyRootPath map[string]bool
)
if depth == eager {
eagerUpgrades = tryUpgrade
} else {
isLazyRootPath = make(map[string]bool, len(maxVersion))
for p := range maxVersion {
isLazyRootPath[p] = true
}
for _, m := range tryUpgrade {
isLazyRootPath[m.Path] = true
}
for _, m := range mustSelect {
isLazyRootPath[m.Path] = true
}
allowedRoot := map[module.Version]bool{}
var allowRoot func(m module.Version) error
allowRoot = func(m module.Version) error {
if allowedRoot[m] {
return nil
}
allowedRoot[m] = true
if m.Path == Target.Path {
// Target is already considered to be higher than any possible m, so we
// won't be upgrading to it anyway and there is no point scanning its
// dependencies.
continue
return nil
}
allow(m)
summary, err := goModSummary(m)
if err != nil {
return err
@ -234,12 +258,27 @@ func raiseLimitsForUpgrades(ctx context.Context, maxVersion map[string]string, d
// graph, rather than loading the (potentially-overlapping) subgraph for
// each upgrade individually.
eagerUpgrades = append(eagerUpgrades, m)
continue
return nil
}
for _, r := range summary.require {
allow(r)
if isLazyRootPath[r.Path] {
// r could become a root as the result of an upgrade or downgrade,
// in which case its dependencies will not be pruned out.
// We need to allow those dependencies to be upgraded too.
if err := allowRoot(r); err != nil {
return err
}
} else {
// r will not become a root, so its dependencies don't matter.
// Allow only r itself.
allow(r)
}
}
return nil
}
for _, m := range tryUpgrade {
allowRoot(m)
}
}
@ -268,16 +307,41 @@ func raiseLimitsForUpgrades(ctx context.Context, maxVersion map[string]string, d
}
}
if len(mustSelect) > 0 {
mustGraph, err := readModGraph(ctx, depth, mustSelect)
// Explicitly allow any (transitive) upgrades implied by mustSelect.
nextRoots := append([]module.Version(nil), mustSelect...)
for nextRoots != nil {
module.Sort(nextRoots)
rs := newRequirements(depth, nextRoots, nil)
nextRoots = nil
rs, mustGraph, err := expandGraph(ctx, rs)
if err != nil {
return err
}
for _, r := range mustGraph.BuildList() {
// Some module in mustSelect requires r, so we must allow at least r.Version
// unless it conflicts with an entry in mustSelect.
// Some module in mustSelect requires r, so we must allow at least
// r.Version (unless it conflicts with another entry in mustSelect, in
// which case we will error out either way).
allow(r)
if isLazyRootPath[r.Path] {
if v, ok := rs.rootSelected(r.Path); ok && r.Version == v {
// r is already a root, so its requirements are already included in
// the build list.
continue
}
// The dependencies in mustSelect may upgrade (or downgrade) an existing
// root to match r, which will remain as a root. However, since r is not
// a root of rs, its dependencies have been pruned out of this build
// list. We need to add it back explicitly so that we allow any
// transitive upgrades that r will pull in.
if nextRoots == nil {
nextRoots = rs.rootModules // already capped
}
nextRoots = append(nextRoots, r)
}
}
}

View file

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin || openbsd
// +build darwin openbsd
//go:build (darwin && !ios) || openbsd
// +build darwin,!ios openbsd
package rand

View file

@ -129,3 +129,43 @@ func TestUninitialized(t *testing.T) {
t.Errorf("in uninitialized embed.FS, . is not a directory")
}
}
var (
//go:embed "testdata/hello.txt"
helloT []T
//go:embed "testdata/hello.txt"
helloUint8 []uint8
//go:embed "testdata/hello.txt"
helloEUint8 []EmbedUint8
//go:embed "testdata/hello.txt"
helloBytes EmbedBytes
//go:embed "testdata/hello.txt"
helloString EmbedString
)
type T byte
type EmbedUint8 uint8
type EmbedBytes []byte
type EmbedString string
// golang.org/issue/47735
func TestAliases(t *testing.T) {
all := testDirAll
want, e := all.ReadFile("testdata/hello.txt")
if e != nil {
t.Fatal("ReadFile:", e)
}
check := func(g interface{}) {
got := reflect.ValueOf(g)
for i := 0; i < got.Len(); i++ {
if byte(got.Index(i).Uint()) != want[i] {
t.Fatalf("got %v want %v", got.Bytes(), want)
}
}
}
check(helloT)
check(helloUint8)
check(helloEUint8)
check(helloBytes)
check(helloString)
}

View file

@ -4,7 +4,7 @@ go 1.17
require (
golang.org/x/crypto v0.0.0-20210503195802-e9a32991a82e
golang.org/x/net v0.0.0-20210510120150-4163338589ed
golang.org/x/net v0.0.0-20210901185426-6d2eada6345e
golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744 // indirect
golang.org/x/text v0.3.7-0.20210503195748-5c7c50ebbd4f // indirect
)

View file

@ -224,7 +224,6 @@ func (check *Checker) exprList(elist []ast.Expr, allowCommaOk bool) (xlist []*op
// exactly one (possibly invalid or comma-ok) value
xlist = []*operand{&x}
if allowCommaOk && (x.mode == mapindex || x.mode == commaok || x.mode == commaerr) {
x.mode = value
x2 := &operand{mode: value, expr: e, typ: Typ[UntypedBool]}
if x.mode == commaerr {
x2.typ = universeError

View file

@ -276,7 +276,7 @@ func (check *Checker) collectObjects() {
}
if name == "init" {
check.errorf(d.spec.Name, _InvalidInitDecl, "cannot import package as init - init must be a func")
check.errorf(d.spec, _InvalidInitDecl, "cannot import package as init - init must be a func")
return
}

View file

@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin && !ios
// +build darwin,!ios
package unix
import (

View file

@ -4519,6 +4519,15 @@ func (sc *http2serverConn) serve() {
case res := <-sc.wroteFrameCh:
sc.wroteFrame(res)
case res := <-sc.readFrameCh:
// Process any written frames before reading new frames from the client since a
// written frame could have triggered a new stream to be started.
if sc.writingFrameAsync {
select {
case wroteRes := <-sc.wroteFrameCh:
sc.wroteFrame(wroteRes)
default:
}
}
if !sc.processFrameFromReader(res) {
return
}

View file

@ -8,7 +8,7 @@ golang.org/x/crypto/curve25519
golang.org/x/crypto/hkdf
golang.org/x/crypto/internal/subtle
golang.org/x/crypto/poly1305
# golang.org/x/net v0.0.0-20210510120150-4163338589ed
# golang.org/x/net v0.0.0-20210901185426-6d2eada6345e
## explicit; go 1.17
golang.org/x/net/dns/dnsmessage
golang.org/x/net/http/httpguts