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

x/image/riff: (*Reader) Next() drops io.ReadFull error #16236

Closed
richardlehane opened this issue Jul 1, 2016 · 1 comment
Closed

x/image/riff: (*Reader) Next() drops io.ReadFull error #16236

richardlehane opened this issue Jul 1, 2016 · 1 comment

Comments

@richardlehane
Copy link

I'm getting panics and memory issues using golang.org/x/image/riff package with malformed riff files.

E.g. https://play.golang.org/p/cCN1VQ4Dz2

These seem to be due to an IO error being dropped in the (*Reader) Next() method.

From line 132 in https://github.com/golang/image/blob/master/riff/riff.go:

    if _, err = io.ReadFull(z.r, z.buf[:chunkHeaderSize]); err != nil {
        if z.err == io.EOF || z.err == io.ErrUnexpectedEOF {
            z.err = errShortChunkHeader
        }
        return FourCC{}, 0, nil, z.err
    }
    chunkID = FourCC{z.buf[0], z.buf[1], z.buf[2], z.buf[3]}
    z.chunkLen = u32(z.buf[4:])
    z.padded = z.chunkLen&1 == 1
    z.chunkReader = &chunkReader{z}
    return chunkID, z.chunkLen, z.chunkReader, nil

The err var in the first line of that snippet is a named return value but it is never used/ returned by the method.

Can fix by assigning the io.ReadFull error to z.err instead:

    if _, z.err = io.ReadFull(z.r, z.buf[:chunkHeaderSize]); z.err != nil {
        if z.err == io.EOF || z.err == io.ErrUnexpectedEOF {
            z.err = errShortChunkHeader
        }
        return FourCC{}, 0, nil, z.err
    }
    chunkID = FourCC{z.buf[0], z.buf[1], z.buf[2], z.buf[3]}
    z.chunkLen = u32(z.buf[4:])
    z.padded = z.chunkLen&1 == 1
    z.chunkReader = &chunkReader{z}
    return chunkID, z.chunkLen, z.chunkReader, nil

as at golang/image@ 8550bb5

@bradfitz bradfitz changed the title image/riff: (*Reader) Next() drops io.ReadFull error x/image/riff: (*Reader) Next() drops io.ReadFull error Jul 1, 2016
@bradfitz bradfitz added this to the Unreleased milestone Jul 1, 2016
@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Jul 7, 2017
mrhyperbit23z0d added a commit to mrhyperbit23z0d/bhegde8 that referenced this issue Jun 6, 2022
Fixes golang/go#16236

Change-Id: I0e524054d0702a6487ff47d86aed6bf58f4ba3f2
Reviewed-on: https://go-review.googlesource.com/24638
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
GalaxyForcew added a commit to GalaxyForcew/A1bisshy that referenced this issue Jun 6, 2022
Fixes golang/go#16236

Change-Id: I0e524054d0702a6487ff47d86aed6bf58f4ba3f2
Reviewed-on: https://go-review.googlesource.com/24638
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
yi-ge3 added a commit to yi-ge3/wislie that referenced this issue Jun 6, 2022
Fixes golang/go#16236

Change-Id: I0e524054d0702a6487ff47d86aed6bf58f4ba3f2
Reviewed-on: https://go-review.googlesource.com/24638
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
balloontmz6 added a commit to balloontmz6/Likewise42l that referenced this issue Jun 6, 2022
Fixes golang/go#16236

Change-Id: I0e524054d0702a6487ff47d86aed6bf58f4ba3f2
Reviewed-on: https://go-review.googlesource.com/24638
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
snapbakkhfbav added a commit to snapbakkhfbav/SayedBaladohr that referenced this issue Oct 6, 2022
Fixes golang/go#16236

Change-Id: I0e524054d0702a6487ff47d86aed6bf58f4ba3f2
Reviewed-on: https://go-review.googlesource.com/24638
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
MiderWong5ddop added a commit to MiderWong5ddop/sidie88f that referenced this issue Oct 7, 2022
Fixes golang/go#16236

Change-Id: I0e524054d0702a6487ff47d86aed6bf58f4ba3f2
Reviewed-on: https://go-review.googlesource.com/24638
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
rorypeckwnt4v added a commit to rorypeckwnt4v/LearnByBhanuPrataph that referenced this issue Oct 7, 2022
Fixes golang/go#16236

Change-Id: I0e524054d0702a6487ff47d86aed6bf58f4ba3f2
Reviewed-on: https://go-review.googlesource.com/24638
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
egorovcharenko9 added a commit to egorovcharenko9/RiceBIOC470z that referenced this issue Oct 7, 2022
Fixes golang/go#16236

Change-Id: I0e524054d0702a6487ff47d86aed6bf58f4ba3f2
Reviewed-on: https://go-review.googlesource.com/24638
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
RafayGhafoorf added a commit to RafayGhafoorf/dustinsand8 that referenced this issue Oct 7, 2022
Fixes golang/go#16236

Change-Id: I0e524054d0702a6487ff47d86aed6bf58f4ba3f2
Reviewed-on: https://go-review.googlesource.com/24638
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
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

4 participants