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/base32: The decoder returned by NewDecoder sometimes drops errors #20044

Closed
akalin-keybase opened this issue Apr 19, 2017 · 8 comments
Closed
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@akalin-keybase
Copy link

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 to base32.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.

@bradfitz bradfitz added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. help wanted NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 21, 2017
@bradfitz bradfitz added this to the Go1.9Maybe milestone Apr 21, 2017
@bradfitz
Copy link
Contributor

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.

@markdryan
Copy link
Contributor

@bradfitz Any objections if I take a look at this?

@bradfitz
Copy link
Contributor

@markdryan, all yours.

@markdryan
Copy link
Contributor

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.

@gopherbot
Copy link

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

@akalin-keybase
Copy link
Author

Looks like that patch needs some reviewers...

@akalin-keybase
Copy link
Author

ascii85, base64 have similar bugs -- should I file new bugs for those?

@bradfitz
Copy link
Contributor

We shouldn't reuse this bug.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants