Skip to content

image/jpeg: Decoding returns EOF instead of ErrUnexpectedEOF for JPEG files with missing segments #6450

Description

@rakyll
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)

Activity

  1. robpike commented on Sep 23, 2013

    @robpike
    Contributor

    Comment 1:

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

    Owner changed to @nigeltao.

    Status changed to Accepted.

  2. rsc commented on Nov 27, 2013

    @rsc
    Contributor

    Comment 2:

    Labels changed: added go1.3maybe.

  3. gopherbot commented on Nov 27, 2013

    @gopherbot
    Contributor

    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.
  4. rakyll commented on Nov 28, 2013

    @rakyll
    ContributorAuthor

    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.
  5. rsc commented on Dec 4, 2013

    @rsc
    Contributor

    Comment 5:

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

  6. rsc commented on Dec 4, 2013

    @rsc
    Contributor

    Comment 6:

    Labels changed: added repo-main.

  7. nigeltao commented on Feb 28, 2014

    @nigeltao
    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.
  8. nigeltao commented on Feb 28, 2014

    @nigeltao
    Contributor

    Comment 8:

    This issue was closed by revision c2013e8.

    Status changed to Fixed.

  9. locked and limited conversation to collaborators on Jun 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions