You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Change https://go.dev/cl/607499 mentions this issue: encoding/base32, encoding/base64: document Decode to short buffer
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
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: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.The text was updated successfully, but these errors were encountered: