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/bmp: hang on degenerate image #10746

Closed
dvyukov opened this issue May 7, 2015 · 1 comment
Closed

x/image/bmp: hang on degenerate image #10746

dvyukov opened this issue May 7, 2015 · 1 comment

Comments

@dvyukov
Copy link
Member

dvyukov commented May 7, 2015

The following program takes 20 seconds to run. The image size is 0x538771456, so it passes the image size sanity check after DecodeConfig. But bmp package actually reads in and decodes every row. Decode should either produce an error or instantly return a 0x0 image.

package main

import (
    "bytes"
    "golang.org/x/image/bmp"
)

func main() {
    data := []byte("BM6\x03\x00\x00\x00\x00\x00\x006\x00\x00\x00(\x00\x00\x00\x00\x00" +
        "\x00\x00\x00\x00\x1d \x01\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x1d V" +
        "a\x00lue>`\x0e\x00\x00n\t\x00\x00\x00\x00\x00\x00\x00\x00" +
        "\x00\x00")
    cfg, err := bmp.DecodeConfig(bytes.NewReader(data))
    if err != nil {
        return 0
    }
    if cfg.Width*cfg.Height > 1e6 {
        return 0
    }
    img, err := bmp.Decode(bytes.NewReader(data))
    if err != nil {
        return
    }
    var w bytes.Buffer
    bmp.Encode(&w, img)
}

on commit 4a3ed0c1249ebedab3c715c000034638f1cad002

@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Jun 25, 2016
mrhyperbit23z0d added a commit to mrhyperbit23z0d/bhegde8 that referenced this issue Jun 6, 2022
It should be quick regardless of how large H is.

Fixes golang/go#10746

Change-Id: Icde36047e88d9786e64f44724b7ba8b38db2a33f
Reviewed-on: https://go-review.googlesource.com/9836
Reviewed-by: Nigel Tao <nigeltao@golang.org>
GalaxyForcew added a commit to GalaxyForcew/A1bisshy that referenced this issue Jun 6, 2022
It should be quick regardless of how large H is.

Fixes golang/go#10746

Change-Id: Icde36047e88d9786e64f44724b7ba8b38db2a33f
Reviewed-on: https://go-review.googlesource.com/9836
Reviewed-by: Nigel Tao <nigeltao@golang.org>
yi-ge3 added a commit to yi-ge3/wislie that referenced this issue Jun 6, 2022
It should be quick regardless of how large H is.

Fixes golang/go#10746

Change-Id: Icde36047e88d9786e64f44724b7ba8b38db2a33f
Reviewed-on: https://go-review.googlesource.com/9836
Reviewed-by: Nigel Tao <nigeltao@golang.org>
balloontmz6 added a commit to balloontmz6/Likewise42l that referenced this issue Jun 6, 2022
It should be quick regardless of how large H is.

Fixes golang/go#10746

Change-Id: Icde36047e88d9786e64f44724b7ba8b38db2a33f
Reviewed-on: https://go-review.googlesource.com/9836
Reviewed-by: Nigel Tao <nigeltao@golang.org>
snapbakkhfbav added a commit to snapbakkhfbav/SayedBaladohr that referenced this issue Oct 6, 2022
It should be quick regardless of how large H is.

Fixes golang/go#10746

Change-Id: Icde36047e88d9786e64f44724b7ba8b38db2a33f
Reviewed-on: https://go-review.googlesource.com/9836
Reviewed-by: Nigel Tao <nigeltao@golang.org>
MiderWong5ddop added a commit to MiderWong5ddop/sidie88f that referenced this issue Oct 7, 2022
It should be quick regardless of how large H is.

Fixes golang/go#10746

Change-Id: Icde36047e88d9786e64f44724b7ba8b38db2a33f
Reviewed-on: https://go-review.googlesource.com/9836
Reviewed-by: Nigel Tao <nigeltao@golang.org>
rorypeckwnt4v added a commit to rorypeckwnt4v/LearnByBhanuPrataph that referenced this issue Oct 7, 2022
It should be quick regardless of how large H is.

Fixes golang/go#10746

Change-Id: Icde36047e88d9786e64f44724b7ba8b38db2a33f
Reviewed-on: https://go-review.googlesource.com/9836
Reviewed-by: Nigel Tao <nigeltao@golang.org>
egorovcharenko9 added a commit to egorovcharenko9/RiceBIOC470z that referenced this issue Oct 7, 2022
It should be quick regardless of how large H is.

Fixes golang/go#10746

Change-Id: Icde36047e88d9786e64f44724b7ba8b38db2a33f
Reviewed-on: https://go-review.googlesource.com/9836
Reviewed-by: Nigel Tao <nigeltao@golang.org>
RafayGhafoorf added a commit to RafayGhafoorf/dustinsand8 that referenced this issue Oct 7, 2022
It should be quick regardless of how large H is.

Fixes golang/go#10746

Change-Id: Icde36047e88d9786e64f44724b7ba8b38db2a33f
Reviewed-on: https://go-review.googlesource.com/9836
Reviewed-by: Nigel Tao <nigeltao@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

3 participants