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

Closed
akalin opened this issue May 24, 2017 · 2 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@akalin
Copy link

akalin commented May 24, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.8.2

What operating system and processor architecture are you using (go env)?

darwin amd64

What did you do?

When passing an io.Reader to ascii85.NewDecoder, if that reader emits valid ascii85 input and an error, I would expect that error to be propagated. Instead, it is dropped.

Example: https://play.golang.org/p/b53MrmCtSX

In this case, it's because d.readErr isn't being returned in the branch that handles copying from d.out and then returns.

This is another instance of #20044 .

@dsnet dsnet added this to the Go1.10 milestone May 24, 2017
@dsnet dsnet added the NeedsFix The path to resolution is known, but the work has not been done. label May 24, 2017
@markdryan
Copy link
Contributor

markdryan commented Jun 7, 2017

This one doesn't actually look like a bug to me. Although the read error is not returned on the initial call to decoder.Read it is saved in d.readErr and neither lost or overwritten. It will be returned on the next call to decoder.Read. This behaviour is compatible with the io.Reader specification.

When Read encounters an error or end-of-file condition after successfully reading n > 0 bytes, it returns the number of bytes read. It may return the (non-nil) error from the same call or return the error (and n == 0) from a subsequent call.

If we insert a second call to decoder.Read directly after the first, e.g.,

  n, err := decoder.Read(buf)
+ n, err = decoder.Read(buf)
  if err != fakeErr {

the test passes as fakeError is returned.

@akalin
Copy link
Author

akalin commented Jun 7, 2017

Ah, you're right! Here's an updated test: https://play.golang.org/p/J5KWJI-iHW

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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