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/jpeg: Decoding returns EOF instead of ErrUnexpectedEOF for JPEG files with missing segments #6450

Closed
rakyll opened this issue Sep 22, 2013 · 8 comments

Comments

@rakyll
Copy link
Contributor

rakyll commented Sep 22, 2013

What steps will reproduce the problem?

import (
    "image"
    _ "image/jpeg"
)
img, format, err := image.Decode(jpegImageWithMissingSegmentsReader)


What is the expected output?
Unexpected EOF should be returned.

What do you see instead?
EOF is returned in some cases if there are missing segments in the image file. Attached
file reproduces the problem.

Which operating system are you using?
Darwin Kernel Version 12.4.0

Which version are you using?  (run 'go version')
go version go1.1.2 darwin/386

Attachments:

  1. Stray_Kitten.jpg (131072 bytes)
@robpike
Copy link
Contributor

robpike commented Sep 23, 2013

Comment 1:

Labels changed: added priority-later, packagebug, removed priority-triage.

Owner changed to @nigeltao.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 2:

Labels changed: added go1.3maybe.

@gopherbot
Copy link

Comment 3 by rdamazio@google.com:

Just a thought - maybe it should return err AND img, with img containing partial
contents like what's rendered above.

@rakyll
Copy link
Contributor Author

rakyll commented Nov 28, 2013

Comment 4:

IMHO, encoding problems should not be classified as show stoppers. But, partial contents
will require repairment and I'm not sure if it should happen in this package.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 5:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 6:

Labels changed: added repo-main.

@nigeltao
Copy link
Contributor

Comment 7:

I agree with the general sentiment, although I think it should be a jpeg.FormatError
instead of io.ErrUnexpectedEOF.
As for comment #3, I generally don't like being "liberal in what we accept"; this is
arguably simply an invalid JPEG image. Yes, there is already precedent in the image/jpeg
code in being a little liberal, but I didn't really like that either. If your program
really needs to accept corrupted JPEG images, then you can always fork image/jpeg.

@nigeltao
Copy link
Contributor

Comment 8:

This issue was closed by revision c2013e8.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
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

5 participants