Skip to content

Commit

Permalink
[dev.boringcrypto] all: merge master into dev.boringcrypto
Browse files Browse the repository at this point in the history
Change-Id: I52009bf809dda4fbcff03aa82d0ea8aa2a978fa2
  • Loading branch information
chressie committed Apr 20, 2022
2 parents 1f11660 + d68a8d0 commit e07d639
Show file tree
Hide file tree
Showing 801 changed files with 20,788 additions and 7,251 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,7 @@ Wei Guangjing <vcc.163@gmail.com>
Weichao Tang <tevic.tt@gmail.com>
Weixie Cui <cuiweixie@gmail.com> <523516579@qq.com>
Wembley G. Leach, Jr <wembley.gl@gmail.com>
Wen Yang <yangwen.yw@gmail.com>
Will Faught <will.faught@gmail.com>
Will Storey <will@summercat.com>
Willem van der Schyff <willemvds@gmail.com>
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -2746,6 +2746,7 @@ Weichao Tang <tevic.tt@gmail.com>
Weilu Jia <optix2000@gmail.com>
Weixie Cui <cuiweixie@gmail.com> <523516579@qq.com>
Wembley G. Leach, Jr <wembley.gl@gmail.com>
Wen Yang <yangwen.yw@gmail.com>
Wenlei (Frank) He <wlhe@google.com>
Wenzel Lowe <lowewenzel@gmail.com>
Wil Selwood <wselwood@gmail.com>
Expand Down
1 change: 1 addition & 0 deletions api/next/35044.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkg crypto/x509, method (*CertPool) Clone() *CertPool #35044
2 changes: 2 additions & 0 deletions api/next/42710.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pkg hash/maphash, func Bytes(Seed, []uint8) uint64 #42710
pkg hash/maphash, func String(Seed, string) uint64 #42710
1 change: 1 addition & 0 deletions api/next/50340.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkg sort, func Find(int, func(int) int) (int, bool) #50340
9 changes: 9 additions & 0 deletions api/next/50674.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pkg crypto/x509, func ParseRevocationList([]uint8) (*RevocationList, error) #50674
pkg crypto/x509, method (*RevocationList) CheckSignatureFrom(*Certificate) error #50674
pkg crypto/x509, type RevocationList struct, AuthorityKeyId []uint8 #50674
pkg crypto/x509, type RevocationList struct, Extensions []pkix.Extension #50674
pkg crypto/x509, type RevocationList struct, Issuer pkix.Name #50674
pkg crypto/x509, type RevocationList struct, Raw []uint8 #50674
pkg crypto/x509, type RevocationList struct, RawIssuer []uint8 #50674
pkg crypto/x509, type RevocationList struct, RawTBSRevocationList []uint8 #50674
pkg crypto/x509, type RevocationList struct, Signature []uint8 #50674
61 changes: 61 additions & 0 deletions api/next/51082.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
pkg go/doc, method (*Package) HTML(string) []uint8 #51082
pkg go/doc, method (*Package) Markdown(string) []uint8 #51082
pkg go/doc, method (*Package) Parser() *comment.Parser #51082
pkg go/doc, method (*Package) Printer() *comment.Printer #51082
pkg go/doc, method (*Package) Synopsis(string) string #51082
pkg go/doc, method (*Package) Text(string) []uint8 #51082
pkg go/doc/comment, func DefaultLookupPackage(string) (string, bool) #51082
pkg go/doc/comment, method (*DocLink) DefaultURL(string) string #51082
pkg go/doc/comment, method (*Heading) DefaultID() string #51082
pkg go/doc/comment, method (*List) BlankBefore() bool #51082
pkg go/doc/comment, method (*List) BlankBetween() bool #51082
pkg go/doc/comment, method (*Parser) Parse(string) *Doc #51082
pkg go/doc/comment, method (*Printer) Comment(*Doc) []uint8 #51082
pkg go/doc/comment, method (*Printer) HTML(*Doc) []uint8 #51082
pkg go/doc/comment, method (*Printer) Markdown(*Doc) []uint8 #51082
pkg go/doc/comment, method (*Printer) Text(*Doc) []uint8 #51082
pkg go/doc/comment, type Block interface, unexported methods #51082
pkg go/doc/comment, type Code struct #51082
pkg go/doc/comment, type Code struct, Text string #51082
pkg go/doc/comment, type Doc struct #51082
pkg go/doc/comment, type Doc struct, Content []Block #51082
pkg go/doc/comment, type Doc struct, Links []*LinkDef #51082
pkg go/doc/comment, type DocLink struct #51082
pkg go/doc/comment, type DocLink struct, ImportPath string #51082
pkg go/doc/comment, type DocLink struct, Name string #51082
pkg go/doc/comment, type DocLink struct, Recv string #51082
pkg go/doc/comment, type DocLink struct, Text []Text #51082
pkg go/doc/comment, type Heading struct #51082
pkg go/doc/comment, type Heading struct, Text []Text #51082
pkg go/doc/comment, type Italic string #51082
pkg go/doc/comment, type Link struct #51082
pkg go/doc/comment, type Link struct, Auto bool #51082
pkg go/doc/comment, type Link struct, Text []Text #51082
pkg go/doc/comment, type Link struct, URL string #51082
pkg go/doc/comment, type LinkDef struct #51082
pkg go/doc/comment, type LinkDef struct, Text string #51082
pkg go/doc/comment, type LinkDef struct, URL string #51082
pkg go/doc/comment, type LinkDef struct, Used bool #51082
pkg go/doc/comment, type List struct #51082
pkg go/doc/comment, type List struct, ForceBlankBefore bool #51082
pkg go/doc/comment, type List struct, ForceBlankBetween bool #51082
pkg go/doc/comment, type List struct, Items []*ListItem #51082
pkg go/doc/comment, type ListItem struct #51082
pkg go/doc/comment, type ListItem struct, Content []Block #51082
pkg go/doc/comment, type ListItem struct, Number string #51082
pkg go/doc/comment, type Paragraph struct #51082
pkg go/doc/comment, type Paragraph struct, Text []Text #51082
pkg go/doc/comment, type Parser struct #51082
pkg go/doc/comment, type Parser struct, LookupPackage func(string) (string, bool) #51082
pkg go/doc/comment, type Parser struct, LookupSym func(string, string) bool #51082
pkg go/doc/comment, type Parser struct, Words map[string]string #51082
pkg go/doc/comment, type Plain string #51082
pkg go/doc/comment, type Printer struct #51082
pkg go/doc/comment, type Printer struct, DocLinkBaseURL string #51082
pkg go/doc/comment, type Printer struct, DocLinkURL func(*DocLink) string #51082
pkg go/doc/comment, type Printer struct, HeadingID func(*Heading) string #51082
pkg go/doc/comment, type Printer struct, HeadingLevel int #51082
pkg go/doc/comment, type Printer struct, TextCodePrefix string #51082
pkg go/doc/comment, type Printer struct, TextPrefix string #51082
pkg go/doc/comment, type Printer struct, TextWidth int #51082
pkg go/doc/comment, type Text interface, unexported methods #51082
2 changes: 2 additions & 0 deletions api/next/51644.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pkg encoding/binary, func AppendUvarint([]uint8, uint64) []uint8 #51644
pkg encoding/binary, func AppendVarint([]uint8, int64) []uint8 #51644
47 changes: 43 additions & 4 deletions doc/go1.19.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,22 @@ <h2 id="tools">Tools</h2>
</p>
<h3 id="go-command">Go command</h3>
<p>
TODO: complete this section, or delete if not needed
TODO: complete this section.
</p>

<!-- https://go.dev/issue/51461 -->
<p>
The <code>-trimpath</code> flag, if set, is now included in the build settings
stamped into Go binaries by <code>go</code> <code>build</code>, and can be
examined using
<a href="https://pkg.go.dev/cmd/go#hdr-Print_Go_version"><code>go</code> <code>version</code> <code>-m</code></a>
or <a href="https://pkg.go.dev/runtime/debug#ReadBuildInfo"><code>debug.ReadBuildInfo</code></a>.
</p>
<p>
<code>go</code> <code>generate</code> now sets the <code>GOROOT</code>
environment variable explicitly in the generator's environment, so that
generators can locate the correct <code>GOROOT</code> even if built
with <code>-trimpath</code>.
</p>

<h4 id="go-unix">New <code>unix</code> build constraint</h4>
Expand Down Expand Up @@ -76,6 +91,19 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
<p>
TODO: complete this section
</p>

<dl id="image/draw"><dt><a href="/pkg/image/draw/">image/draw</a></dt>
<dd>
<p><!-- CL 396795 -->
<code>Draw</code> with the <code>Src</code> operator preserves
non-premultiplied-alpha colors when destination and source images are
both <code>*image.NRGBA</code> (or both <code>*image.NRGBA64</code>).
This reverts a behavior change accidentally introduced by a Go 1.18
library optimization, to match the behavior in Go 1.17 and earlier.
</p>
</dd>
</dl><!-- image/draw -->

<dl id="net"><dt><a href="/pkg/net/">net</a></dt>
<dd>
<p><!-- CL 386016 -->
Expand All @@ -93,9 +121,9 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
<p><!-- CL 396877 -->
When a net package function or method returns an "I/O timeout"
error, the error will now satisfy <code>errors.Is(err,
context.Canceled)</code>. When a net package function returns
an "operation was canceled" error, the error will now satisfy
<code>errors.Is(err, context.DeadlineExceeded)</code>.
context.DeadlineExceeded)</code>. When a net package function
returns an "operation was canceled" error, the error will now
satisfy <code>errors.Is(err, context.Canceled)</code>.
These changes are intended to make it easier for code to test
for cases in which a context cancelation or timeout causes a net
package function or method to return an error, while preserving
Expand All @@ -104,6 +132,17 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
</dd>
</dl><!-- net -->

<dl id="runtime"><dt><a href="/pkg/runtime/">runtime</a></dt>
<dd>
<p><!-- https://go.dev/issue/51461 -->
The <code>GOROOT</code> function now returns the empty string
(instead of <code>"go"</code>) when the binary was built with
the <code>-trimpath</code> flag set and the <code>GOROOT</code>
variable is not set in the process environment.
</p>
</dd>
</dl><!-- runtime -->

<dl id="strconv"><dt><a href="/pkg/strconv/">strconv</a></dt>
<dd>
<p><!-- CL 397255 -->
Expand Down
7 changes: 3 additions & 4 deletions misc/cgo/gmp/gmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,9 @@ func (z *Int) Abs(x *Int) *Int {

// CmpInt compares x and y. The result is
//
// -1 if x < y
// 0 if x == y
// +1 if x > y
//
// -1 if x < y
// 0 if x == y
// +1 if x > y
func CmpInt(x, y *Int) int {
x.doinit()
y.doinit()
Expand Down
49 changes: 49 additions & 0 deletions misc/cgo/testcshared/cshared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package cshared_test

import (
"bufio"
"bytes"
"debug/elf"
"debug/pe"
Expand Down Expand Up @@ -838,3 +839,51 @@ func TestGo2C2Go(t *testing.T) {
run(t, goenv, "go", "build", "-o", bin, "./go2c2go/m2")
runExe(t, runenv, bin)
}

func TestIssue36233(t *testing.T) {
t.Parallel()

// Test that the export header uses GoComplex64 and GoComplex128
// for complex types.

tmpdir, err := os.MkdirTemp("", "cshared-TestIssue36233")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmpdir)

const exportHeader = "issue36233.h"

run(t, nil, "go", "tool", "cgo", "-exportheader", exportHeader, "-objdir", tmpdir, "./issue36233/issue36233.go")
data, err := os.ReadFile(exportHeader)
if err != nil {
t.Fatal(err)
}

funcs := []struct{ name, signature string }{
{"exportComplex64", "GoComplex64 exportComplex64(GoComplex64 v)"},
{"exportComplex128", "GoComplex128 exportComplex128(GoComplex128 v)"},
{"exportComplexfloat", "GoComplex64 exportComplexfloat(GoComplex64 v)"},
{"exportComplexdouble", "GoComplex128 exportComplexdouble(GoComplex128 v)"},
}

scanner := bufio.NewScanner(bytes.NewReader(data))
var found int
for scanner.Scan() {
b := scanner.Bytes()
for _, fn := range funcs {
if bytes.Contains(b, []byte(fn.name)) {
found++
if !bytes.Contains(b, []byte(fn.signature)) {
t.Errorf("function signature mismatch; got %q, want %q", b, fn.signature)
}
}
}
}
if err = scanner.Err(); err != nil {
t.Errorf("scanner encountered error: %v", err)
}
if found != len(funcs) {
t.Error("missing functions")
}
}
29 changes: 29 additions & 0 deletions misc/cgo/testcshared/testdata/issue36233/issue36233.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2022 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

// #include <complex.h>
import "C"

//export exportComplex64
func exportComplex64(v complex64) complex64 {
return v
}

//export exportComplex128
func exportComplex128(v complex128) complex128 {
return v
}

//export exportComplexfloat
func exportComplexfloat(v C.complexfloat) C.complexfloat {
return v
}

//export exportComplexdouble
func exportComplexdouble(v C.complexdouble) C.complexdouble {
return v
}

func main() {}
8 changes: 5 additions & 3 deletions misc/ios/go_ios_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
// binary.
//
// This script requires that three environment variables be set:
// GOIOS_DEV_ID: The codesigning developer id or certificate identifier
// GOIOS_APP_ID: The provisioning app id prefix. Must support wildcard app ids.
// GOIOS_TEAM_ID: The team id that owns the app id prefix.
//
// GOIOS_DEV_ID: The codesigning developer id or certificate identifier
// GOIOS_APP_ID: The provisioning app id prefix. Must support wildcard app ids.
// GOIOS_TEAM_ID: The team id that owns the app id prefix.
//
// $GOROOT/misc/ios contains a script, detect.go, that attempts to autodetect these.
package main

Expand Down
9 changes: 6 additions & 3 deletions src/archive/tar/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,11 @@ func (s sparseEntry) endOffset() int64 { return s.Offset + s.Length }
// that the file has no data in it, which is rather odd.
//
// As an example, if the underlying raw file contains the 10-byte data:
//
// var compactFile = "abcdefgh"
//
// And the sparse map has the following entries:
//
// var spd sparseDatas = []sparseEntry{
// {Offset: 2, Length: 5}, // Data fragment for 2..6
// {Offset: 18, Length: 3}, // Data fragment for 18..20
Expand All @@ -235,6 +237,7 @@ func (s sparseEntry) endOffset() int64 { return s.Offset + s.Length }
// }
//
// Then the content of the resulting sparse file with a Header.Size of 25 is:
//
// var sparseFile = "\x00"*2 + "abcde" + "\x00"*11 + "fgh" + "\x00"*4
type (
sparseDatas []sparseEntry
Expand Down Expand Up @@ -293,9 +296,9 @@ func alignSparseEntries(src []sparseEntry, size int64) []sparseEntry {
// The input must have been already validated.
//
// This function mutates src and returns a normalized map where:
// * adjacent fragments are coalesced together
// * only the last fragment may be empty
// * the endOffset of the last fragment is the total size
// - adjacent fragments are coalesced together
// - only the last fragment may be empty
// - the endOffset of the last fragment is the total size
func invertSparseEntries(src []sparseEntry, size int64) []sparseEntry {
dst := src[:0]
var pre sparseEntry
Expand Down
6 changes: 3 additions & 3 deletions src/archive/tar/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,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 {
Expand Down
1 change: 1 addition & 0 deletions src/archive/tar/strconv.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ func formatPAXRecord(k, v string) (string, error) {

// validPAXRecord reports whether the key-value pair is valid where each
// record is formatted as:
//
// "%d %s=%s\n" % (size, key, value)
//
// Keys and values should be UTF-8, but the number of bad writers out there
Expand Down
3 changes: 3 additions & 0 deletions src/archive/zip/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ func (r *checksumReader) Read(b []byte) (n int, err error) {
n, err = r.rc.Read(b)
r.hash.Write(b[:n])
r.nread += uint64(n)
if r.nread > r.f.UncompressedSize64 {
return 0, ErrFormat
}
if err == nil {
return
}
Expand Down
27 changes: 27 additions & 0 deletions src/archive/zip/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1407,3 +1407,30 @@ func TestCVE202141772(t *testing.T) {
t.Errorf("Inconsistent name in info entry: %v", name)
}
}

func TestUnderSize(t *testing.T) {
z, err := OpenReader("testdata/readme.zip")
if err != nil {
t.Fatal(err)
}
defer z.Close()

for _, f := range z.File {
f.UncompressedSize64 = 1
}

for _, f := range z.File {
t.Run(f.Name, func(t *testing.T) {
rd, err := f.Open()
if err != nil {
t.Fatal(err)
}
defer rd.Close()

_, err = io.Copy(io.Discard, rd)
if err != ErrFormat {
t.Fatalf("Error mismatch\n\tGot: %v\n\tWant: %v", err, ErrFormat)
}
})
}
}
Loading

0 comments on commit e07d639

Please sign in to comment.