Navigation Menu

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

Comments

@dvyukov
Copy link
Member

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

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

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

@davecheney
Copy link
Contributor

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 ?

@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
Development

No branches or pull requests

6 participants