diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-09-16 16:09:35 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-09-16 16:48:19 -0700 |
commit | 54866f7a81a2af4a6097146a1c78bd09bb437883 (patch) | |
tree | 4de6eb05a5d33a651cc25dc13296f8e4b9876cba /libgo | |
parent | 745781d24cd7562202687cfbe05597ee673d4537 (diff) | |
download | gcc-54866f7a81a2af4a6097146a1c78bd09bb437883.zip gcc-54866f7a81a2af4a6097146a1c78bd09bb437883.tar.gz gcc-54866f7a81a2af4a6097146a1c78bd09bb437883.tar.bz2 |
libgo: update to go1.17.1 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/350414
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/MERGE | 2 | ||||
-rw-r--r-- | libgo/VERSION | 2 | ||||
-rw-r--r-- | libgo/go/archive/zip/reader.go | 2 | ||||
-rw-r--r-- | libgo/go/archive/zip/reader_test.go | 18 | ||||
-rw-r--r-- | libgo/go/cmd/go/internal/modload/edit.go | 86 | ||||
-rw-r--r-- | libgo/go/crypto/rand/rand_getentropy.go | 4 | ||||
-rw-r--r-- | libgo/go/embed/internal/embedtest/embed_test.go | 40 | ||||
-rw-r--r-- | libgo/go/go.mod | 2 | ||||
-rw-r--r-- | libgo/go/go/types/call.go | 1 | ||||
-rw-r--r-- | libgo/go/go/types/resolver.go | 2 | ||||
-rw-r--r-- | libgo/go/internal/syscall/unix/getentropy_darwin.go | 3 | ||||
-rw-r--r-- | libgo/go/net/http/h2_bundle.go | 9 | ||||
-rw-r--r-- | libgo/go/vendor/modules.txt | 2 |
13 files changed, 153 insertions, 20 deletions
diff --git a/libgo/MERGE b/libgo/MERGE index d037d8d..4473f47 100644 --- a/libgo/MERGE +++ b/libgo/MERGE @@ -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. diff --git a/libgo/VERSION b/libgo/VERSION index efcff29..844393b 100644 --- a/libgo/VERSION +++ b/libgo/VERSION @@ -1 +1 @@ -go1.17 +go1.17.1 diff --git a/libgo/go/archive/zip/reader.go b/libgo/go/archive/zip/reader.go index 2d53f4c..c91a8d0 100644 --- a/libgo/go/archive/zip/reader.go +++ b/libgo/go/archive/zip/reader.go @@ -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 diff --git a/libgo/go/archive/zip/reader_test.go b/libgo/go/archive/zip/reader_test.go index 37dafe6..afb03ac 100644 --- a/libgo/go/archive/zip/reader_test.go +++ b/libgo/go/archive/zip/reader_test.go @@ -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) + } +} diff --git a/libgo/go/cmd/go/internal/modload/edit.go b/libgo/go/cmd/go/internal/modload/edit.go index c350b9d..47f236c 100644 --- a/libgo/go/cmd/go/internal/modload/edit.go +++ b/libgo/go/cmd/go/internal/modload/edit.go @@ -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) + } } } diff --git a/libgo/go/crypto/rand/rand_getentropy.go b/libgo/go/crypto/rand/rand_getentropy.go index f82018a..dd72537 100644 --- a/libgo/go/crypto/rand/rand_getentropy.go +++ b/libgo/go/crypto/rand/rand_getentropy.go @@ -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 diff --git a/libgo/go/embed/internal/embedtest/embed_test.go b/libgo/go/embed/internal/embedtest/embed_test.go index 2d50f5e..b41359f 100644 --- a/libgo/go/embed/internal/embedtest/embed_test.go +++ b/libgo/go/embed/internal/embedtest/embed_test.go @@ -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) +} diff --git a/libgo/go/go.mod b/libgo/go/go.mod index 379dcf5..a89afcc 100644 --- a/libgo/go/go.mod +++ b/libgo/go/go.mod @@ -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 ) diff --git a/libgo/go/go/types/call.go b/libgo/go/go/types/call.go index 631ea42..336b526 100644 --- a/libgo/go/go/types/call.go +++ b/libgo/go/go/types/call.go @@ -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 diff --git a/libgo/go/go/types/resolver.go b/libgo/go/go/types/resolver.go index 114647a..4892218 100644 --- a/libgo/go/go/types/resolver.go +++ b/libgo/go/go/types/resolver.go @@ -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 } diff --git a/libgo/go/internal/syscall/unix/getentropy_darwin.go b/libgo/go/internal/syscall/unix/getentropy_darwin.go index e1a410a..c75006b 100644 --- a/libgo/go/internal/syscall/unix/getentropy_darwin.go +++ b/libgo/go/internal/syscall/unix/getentropy_darwin.go @@ -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 ( diff --git a/libgo/go/net/http/h2_bundle.go b/libgo/go/net/http/h2_bundle.go index 0e5fbf8..8958a9e 100644 --- a/libgo/go/net/http/h2_bundle.go +++ b/libgo/go/net/http/h2_bundle.go @@ -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 } diff --git a/libgo/go/vendor/modules.txt b/libgo/go/vendor/modules.txt index ff01db5..70d42ed 100644 --- a/libgo/go/vendor/modules.txt +++ b/libgo/go/vendor/modules.txt @@ -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 |