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

image/gif: EOF instead of UnexpectedEOF #11390

Closed
dvyukov opened this issue Jun 24, 2015 · 3 comments
Closed

image/gif: EOF instead of UnexpectedEOF #11390

dvyukov opened this issue Jun 24, 2015 · 3 comments
Assignees
Milestone

Comments

@dvyukov
Copy link
Member

@dvyukov dvyukov commented Jun 24, 2015

The following program prints EOF, which looks weird (whole image decoded?). Jpeg and png print UnexpectedEOF in this case. Gif should also return UnexpectedEOF.

package main

import (
    "bytes"
    "fmt"
    "image/gif"
)

func main() {
    _, err := gif.Decode(bytes.NewReader([]byte{}))
    fmt.Printf("err: %v\n", err)
}

go version devel +3cab476 Sun Jun 21 03:11:01 2015 +0000 linux/amd64

@dvyukov dvyukov changed the title gif: EOF instead of UnexpectedEOF image/gif: EOF instead of UnexpectedEOF Jun 24, 2015
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Jul 11, 2015
@jeffallen
Copy link
Contributor

@jeffallen jeffallen commented Dec 5, 2015

This is easy to just do, but it is hard to know how far to take it. If the header is OK, but there are no bytes after it, then we'll get EOF from someplace else. If there's one byte indicating we should go into readExtension, but no more, then readExtension needs the code change too.

Anyway, I'm posting a CL that fixes the first two spots it can happen.

@gopherbot
Copy link

@gopherbot gopherbot commented Dec 5, 2015

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

@davecheney
Copy link
Contributor

@davecheney davecheney commented Dec 5, 2015

UnexpectedEOF was added for a very specific reason and I would prefer not to see it infect the entire standard library.

What is the use case here. How will knowing that the image is corrupt because it contained less than the necessary bytes of data, vs some other kind of complete but still corrupt state be useful to the caller ?

@gopherbot gopherbot closed this in d1d798d Oct 5, 2016
@golang golang locked and limited conversation to collaborators Oct 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.