crypto/tls: increase readFromUntil buffer size

CL 739980 switched from using a special reader to directly using the
buffer backing memory to read into, but inadvertantly reduced the size
of the buffer that we read into in some circumstances, which could
result in more smaller reads.

Switch back to reading into the largest buffer that we can.

Change-Id: Ic59fe54af6fc671c28a398288bbe603a58cac7e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/769400
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Neal Patel <nealpatel@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
This commit is contained in:
yuhan6665
2026-09-08 21:33:46 -04:00
parent db2d0fd512
commit 3b89eaf6bd
+1 -1
View File
@@ -854,7 +854,7 @@ func (c *Conn) readFromUntil(r io.Reader, n int) error {
// for how much to read ahead.
c.rawInput.Grow(needs + bytes.MinRead)
for {
buf := c.rawInput.AvailableBuffer()[:needs+bytes.MinRead]
buf := c.rawInput.AvailableBuffer()[:c.rawInput.Available()]
n, err := r.Read(buf)
// This write is just to update the internal state of the
// rawInput bytes.Buffer. It cannot fail.