return ErrUnexpectedEOF when Decode input is too short#53
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
ae0acd8 to
29482a2
Compare
The added test cases would fail before this fix:
--- FAIL: TestDecodeError/Empty (0.00s)
unmarshal_test.go:28: Decode("") got "EOF", want "unexpected EOF"
--- FAIL: TestDecodeError/NoSpace (0.00s)
unmarshal_test.go:28: Decode("foo") got "EOF", want "unexpected EOF"
They would still return an error, but they'd just return io.EOF.
While that error signals that we've hit the end of input,
it doesn't signal to the codec user that something went wrong.
An io.EOF is not a worrying error, in many situations.
If the input is empty, or is too short to be a valid git object,
we should return a clear error to signal the operation did not work.
io.ErrUnexpectedEOF is unambiguous,
and will make go-ipfs start erroring on this edge case.
For ipfs/kubo#8378.
29482a2 to
c56b126
Compare
willscott
approved these changes
Sep 4, 2021
Member
|
EDIT: whoops, commented on wrong PR. |
warpfork
approved these changes
Sep 6, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(see commit message)