mirror of https://github.com/golang/go.git
Compare commits
6 Commits
45fee94e40
...
28ed628748
| Author | SHA1 | Date |
|---|---|---|
|
|
28ed628748 | |
|
|
49cdf0c42e | |
|
|
3bf1eecbd3 | |
|
|
8ed23a2936 | |
|
|
ef60769b46 | |
|
|
f7aadef34d |
|
|
@ -82,7 +82,7 @@ func newGCM(cipher Block, nonceSize, tagSize int) (AEAD, error) {
|
|||
|
||||
// NewGCMWithRandomNonce returns the given cipher wrapped in Galois Counter
|
||||
// Mode, with randomly-generated nonces. The cipher must have been created by
|
||||
// [aes.NewCipher].
|
||||
// [crypto/aes.NewCipher].
|
||||
//
|
||||
// It generates a random 96-bit nonce, which is prepended to the ciphertext by Seal,
|
||||
// and is extracted from the ciphertext by Open. The NonceSize of the AEAD is zero,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
PACKAGE issue62640
|
||||
|
||||
IMPORTPATH
|
||||
testdata/issue62640
|
||||
|
||||
FILENAMES
|
||||
testdata/issue62640.go
|
||||
|
||||
TYPES
|
||||
//
|
||||
type E struct{}
|
||||
|
||||
// F should be hidden within S because of the S.F field.
|
||||
func (E) F()
|
||||
|
||||
//
|
||||
type S struct {
|
||||
E
|
||||
F int
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
PACKAGE issue62640
|
||||
|
||||
IMPORTPATH
|
||||
testdata/issue62640
|
||||
|
||||
FILENAMES
|
||||
testdata/issue62640.go
|
||||
|
||||
TYPES
|
||||
//
|
||||
type E struct{}
|
||||
|
||||
// F should be hidden within S because of the S.F field.
|
||||
func (E) F()
|
||||
|
||||
//
|
||||
type S struct {
|
||||
E
|
||||
F int
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
PACKAGE issue62640
|
||||
|
||||
IMPORTPATH
|
||||
testdata/issue62640
|
||||
|
||||
FILENAMES
|
||||
testdata/issue62640.go
|
||||
|
||||
TYPES
|
||||
//
|
||||
type E struct{}
|
||||
|
||||
// F should be hidden within S because of the S.F field.
|
||||
func (E) F()
|
||||
|
||||
//
|
||||
type S struct {
|
||||
E
|
||||
F int
|
||||
}
|
||||
|
||||
// F should be hidden within S because of the S.F field.
|
||||
func (S) F()
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2025 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 issue62640
|
||||
|
||||
type E struct{}
|
||||
|
||||
// F should be hidden within S because of the S.F field.
|
||||
func (E) F() {}
|
||||
|
||||
type S struct {
|
||||
E
|
||||
F int
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ package http
|
|||
import (
|
||||
"bytes"
|
||||
"internal/testenv"
|
||||
"io"
|
||||
"io/fs"
|
||||
"net/url"
|
||||
"os"
|
||||
|
|
@ -189,6 +190,45 @@ func TestNoUnicodeStrings(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
type requestTooLargerResponseWriter struct {
|
||||
called bool
|
||||
}
|
||||
|
||||
func (rw *requestTooLargerResponseWriter) Header() Header { return Header{} }
|
||||
func (rw *requestTooLargerResponseWriter) Write(b []byte) (int, error) { return len(b), nil }
|
||||
func (rw *requestTooLargerResponseWriter) WriteHeader(statusCode int) {}
|
||||
func (rw *requestTooLargerResponseWriter) requestTooLarge() {
|
||||
rw.called = true
|
||||
}
|
||||
|
||||
type wrapper struct {
|
||||
ResponseWriter
|
||||
}
|
||||
|
||||
func (w *wrapper) Unwrap() ResponseWriter {
|
||||
return w.ResponseWriter
|
||||
}
|
||||
|
||||
func TestMaxBytesReaderUnwrapTriggersRequestTooLarge(t *testing.T) {
|
||||
body := strings.NewReader("123456")
|
||||
limit := int64(5)
|
||||
|
||||
innerRw := &requestTooLargerResponseWriter{}
|
||||
wrappedRw := &wrapper{ResponseWriter: innerRw}
|
||||
|
||||
l := MaxBytesReader(wrappedRw, io.NopCloser(body), limit)
|
||||
|
||||
buf := make([]byte, 10)
|
||||
_, err := l.Read(buf)
|
||||
|
||||
if _, ok := err.(*MaxBytesError); !ok {
|
||||
t.Errorf("expected MaxBytesError, got %T", err)
|
||||
}
|
||||
if !innerRw.called {
|
||||
t.Errorf("expected requestTooLarge to be called, but it wasn't")
|
||||
}
|
||||
}
|
||||
|
||||
func TestProtocols(t *testing.T) {
|
||||
var p Protocols
|
||||
if p.HTTP1() {
|
||||
|
|
|
|||
|
|
@ -1243,9 +1243,23 @@ func (l *maxBytesReader) Read(p []byte) (n int, err error) {
|
|||
type requestTooLarger interface {
|
||||
requestTooLarge()
|
||||
}
|
||||
if res, ok := l.w.(requestTooLarger); ok {
|
||||
res.requestTooLarge()
|
||||
// Unwrap the ResponseWriter wrappers until we find one that implements
|
||||
// the server-only requestTooLarger interface, then call requestTooLarge().
|
||||
// This ensures that even if the ResponseWriter is wrapped by a custom implementation,
|
||||
// the underlying server writer can be notified when the request body is too large.
|
||||
rw := l.w
|
||||
for {
|
||||
if res, ok := rw.(requestTooLarger); ok {
|
||||
res.requestTooLarge()
|
||||
break
|
||||
}
|
||||
unwrapper, ok := rw.(rwUnwrapper)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
rw = unwrapper.Unwrap()
|
||||
}
|
||||
|
||||
l.err = &MaxBytesError{l.i}
|
||||
return n, l.err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -312,8 +312,10 @@ type heapArena struct {
|
|||
// during marking.
|
||||
pageSpecials [pagesPerArena / 8]uint8
|
||||
|
||||
// pageUseSpanDartboard is a bitmap that indicates which spans are
|
||||
// heap spans and also gcUsesSpanDartboard.
|
||||
// pageUseSpanInlineMarkBits is a bitmap where each bit corresponds
|
||||
// to a span, as only spans one page in size can have inline mark bits.
|
||||
// The bit indicates that the span has a spanInlineMarkBits struct
|
||||
// stored directly at the top end of the span's memory.
|
||||
pageUseSpanInlineMarkBits [pagesPerArena / 8]uint8
|
||||
|
||||
// checkmarks stores the debug.gccheckmark state. It is only
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2025 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 synctest_test
|
||||
|
||||
import "testing"
|
||||
|
||||
// helperLog is a t.Helper which logs.
|
||||
// Since it is a helper, the log prefix should contain
|
||||
// the caller's file, not helper_test.go.
|
||||
func helperLog(t *testing.T, s string) {
|
||||
t.Helper()
|
||||
t.Log(s)
|
||||
}
|
||||
|
|
@ -140,6 +140,18 @@ func TestRun(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestHelper(t *testing.T) {
|
||||
runTest(t, []string{"-test.v"}, func() {
|
||||
synctest.Test(t, func(t *testing.T) {
|
||||
helperLog(t, "log in helper")
|
||||
})
|
||||
}, `^=== RUN TestHelper
|
||||
synctest_test.go:.* log in helper
|
||||
--- PASS: TestHelper.*
|
||||
PASS
|
||||
$`)
|
||||
}
|
||||
|
||||
func wantPanic(t *testing.T, want string) {
|
||||
if e := recover(); e != nil {
|
||||
if got := fmt.Sprint(e); got != want {
|
||||
|
|
|
|||
|
|
@ -1261,6 +1261,9 @@ func (c *common) Skipped() bool {
|
|||
// When printing file and line information, that function will be skipped.
|
||||
// Helper may be called simultaneously from multiple goroutines.
|
||||
func (c *common) Helper() {
|
||||
if c.isSynctest {
|
||||
c = c.parent
|
||||
}
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
if c.helperPCs == nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue