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

Make Decoder.Decode() return io.UnexpectedEOF instead of io.EOF if CBOR data item is truncated #379

Merged
merged 1 commit into from
Dec 31, 2022

Conversation

fxamacker
Copy link
Owner

If CBOR data item is truncated at EOF, then Decoder.Decode() should return io.UnexpectedEOF instead of io.EOF.

Closes #378

Previously, if CBOR data item was truncated and
the underlying reader reached EOF, Decoder.Decode()
returned io.EOF.

This bug fix makes it return io.UnexpectedEOF because
the CBOR data item was truncated when EOF was encountered.
@fxamacker fxamacker added the bug Something isn't working label Dec 31, 2022
}
return dec.Decode(v)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea to replace recursive call with for-loop. 👍

@fxamacker fxamacker merged commit ecdf545 into master Dec 31, 2022
@fxamacker fxamacker deleted the fxamacker/fix-decoder-reader-error branch January 2, 2023 00:06
@fxamacker fxamacker added this to the v2.5.0 milestone May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Decoder.Decode() should return io.UnexpectedEOF instead of io.EOF if CBOR data item is truncated
2 participants