Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/base64: improve documentation on decoding to a short dst #69024

Closed
hhhapz opened this issue Aug 22, 2024 · 2 comments
Closed

encoding/base64: improve documentation on decoding to a short dst #69024

hhhapz opened this issue Aug 22, 2024 · 2 comments
Labels
Documentation FixPending Issues that have a fix which has not yet been reviewed or submitted.
Milestone

Comments

@hhhapz
Copy link

hhhapz commented Aug 22, 2024

As seen in the issue #50117, providing a dst slice that is valid in size (a multiple of what base64 data decode into) but not large enough for the entire source base64 causes a panic. I was surprised to see that it wasn't documented, and from the function comment:

It writes at most Encoding.DecodedLen(len(src)) bytes to dst and returns the number of bytes written.

A reader would assume that this would therefore decode at most input, (implying a shorter amount would also be possible). I understand that this is not an intended use case, however it should be more explicitly documented that a shorter dst will panic.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/607499 mentions this issue: encoding/base32, encoding/base64: document Decode to short buffer

@cherrymui cherrymui changed the title encoding/base64: Improve documentation on decoding to a short dst encoding/base64: improve documentation on decoding to a short dst Aug 23, 2024
@cherrymui cherrymui added the FixPending Issues that have a fix which has not yet been reviewed or submitted. label Aug 23, 2024
@cherrymui cherrymui added this to the Backlog milestone Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation FixPending Issues that have a fix which has not yet been reviewed or submitted.
Projects
None yet
Development

No branches or pull requests

4 participants