EncodedLen computes the encoded length with int arithmetic that can wrap for very large n, returning a negative or wrapped value. Callers that size an allocation from the result (EncodeToString, AppendEncode) then panic with no indication of the cause, or allocate an undersized buffer. CL 510635 and CL 512200 raised the overflow threshold of the unpadded branches but did not eliminate it, and the padded branches were unchanged: on 32-bit platforms base64.StdEncoding.EncodedLen(1610612736) still returns -2147483648. Make EncodedLen panic when the encoded length does not fit in an int, document the panic, and document the largest n that is guaranteed not to panic. DecodedLen needs no change: its result is at most n and cannot overflow. Fixes #20235 Change-Id: I963a55062a790017b42f49fc3a9178fc3bb024ef GitHub-Last-Rev: 2a7abbb35f7f5e3a2b74c379c29464e01e2206f5 GitHub-Pull-Request: golang/go#80373 Reviewed-on: https://go-review.googlesource.com/c/go/+/799800 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
The Go Programming Language
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 4.0 Attribution license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Download and Install
Binary Distributions
Official binary distributions are available at https://go.dev/dl/.
After downloading a binary release, visit https://go.dev/doc/install for installation instructions.
Install From Source
If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.
Contributing
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.