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/base32: The decoder returned by NewDecoder sometimes drops errors #20044
Comments
Multiple potential issues: use of io.ReadAtLeast drops errors if it reads enough, and base32.go stores into d.err from ReadAtLeast but overwrites it without consulting it d.nbuf >= 8. |
@bradfitz Any objections if I take a look at this? |
@markdryan, all yours. |
I've created a patch that addresses this issue: https://go-review.googlesource.com/c/42094/ The patch fixes the error propagation issues and adds some new unit tests. |
CL https://golang.org/cl/42094 mentions this issue. |
Looks like that patch needs some reviewers... |
ascii85, base64 have similar bugs -- should I file new bugs for those? |
We shouldn't reuse this bug. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.8.1
What operating system and processor architecture are you using (
go env
)?darwin amd64
What did you do?
When passing an
io.Reader
tobase32.NewDecoder
, if that reader emits valid base32 input and an error, I would expect that error to be propagated. Instead, it is dropped.Example: https://play.golang.org/p/Ex-8nNLiZk
In this case, it's because
io.ReadAtLeast
drops errors if the minimum is reached (another surprising thing), but it looks like other encoders (ascii85, base64) exhibit similar behavior, perhaps on purpose. If it is on purpose, it should be documented somewhere.The text was updated successfully, but these errors were encountered: