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

return ErrUnexpectedEOF when Decode input is too short #53

Merged
merged 1 commit into from
Sep 6, 2021

Conversation

mvdan
Copy link
Contributor

@mvdan mvdan commented Sep 4, 2021

(see commit message)

@welcome

This comment has been minimized.

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.
@warpfork
Copy link
Member

warpfork commented Sep 6, 2021

EDIT: whoops, commented on wrong PR.

@mvdan mvdan merged commit 0508c26 into master Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants