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: Decoder assumes padding #13384

Closed
acasajus opened this issue Nov 24, 2015 · 2 comments
Closed

encoding/base64: Decoder assumes padding #13384

acasajus opened this issue Nov 24, 2015 · 2 comments

Comments

@acasajus
Copy link

Hello,

I'm trying to use a bas64.NewDecoder(ba64.RawURLEncoding,in) to decode a b64 stream but I've found that it sometimes misses some bytes. If I use the DecodeString method everything is good, but if I use the reader a byte in the end is lost. If I use a base64.URLEncoding with the required padding everything seems to be working fine.

I've added an example here:

http://play.golang.org/p/pH0Q0FVbn-

@rakyll rakyll changed the title base64 decoder with RawURLEncoding seems to miss some bytes encoding/base64: base64 decoder with RawURLEncoding seems to miss some bytes Nov 28, 2015
@rsc
Copy link
Contributor

rsc commented Dec 28, 2015

Shorter: http://play.golang.org/p/slir-4ZqTT
I believe the problem is the

if d.err != nil || d.nbuf < 4 {

in base64's decoder.Read. The reader expects 4-byte chunks. When unpadded parsing was added, Read was not updated.

@rsc rsc added this to the Go1.6Maybe milestone Dec 28, 2015
@rsc rsc changed the title encoding/base64: base64 decoder with RawURLEncoding seems to miss some bytes encoding/base64: Decoder assumes padding Dec 28, 2015
@gopherbot
Copy link

CL https://golang.org/cl/18330 mentions this issue.

@rsc rsc closed this as completed in 20d745c Jan 8, 2016
@golang golang locked and limited conversation to collaborators Jan 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants