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

Panic on specific broken image [bug] #5

Closed
hedhyw opened this issue Sep 21, 2023 · 2 comments
Closed

Panic on specific broken image [bug] #5

hedhyw opened this issue Sep 21, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@hedhyw
Copy link

hedhyw commented Sep 21, 2023

The library panics in case of uploading a broken image.

Relates to disintegration/imaging#165

Minimal reproducible example

  • poc.tiff by @pic4xiu
  • main.go
    package main
    
    import (
        "fmt"
        "log"
        "os"
    
        "github.com/buckket/go-blurhash"
        "golang.org/x/image/tiff"
    )
    
    func main() {
        imageFile, err := os.Open("poc.tiff")
        if err != nil {
    	    log.Fatal(err)
        }
    
        loadedImage, err := tiff.Decode(imageFile)
        if err != nil {
    	    log.Fatal(err)
        }
    
        str, err := blurhash.Encode(4, 3, loadedImage) // Panic.
        if err != nil {
    	    log.Fatal(err)
        }
    
        fmt.Printf("Hash: %s\n", str)
    }

Panic

panic: runtime error: index out of range [70] with length 65

goroutine 1 [running]:
image.(*Paletted).At(0xc000061d68?, 0x48a050?, 0x101c000061d98?)
        /usr/local/go/src/image/image.go:1159 +0x9a
github.com/buckket/go-blurhash.multiplyBasisFunction({0x4dfb20, 0xc00002c2a0}, {0xc00014c000, 0x24, 0x1?}, 0x4, 0x3)
        .../poc-blurhash/vendor/github.com/buckket/go-blurhash/encode.go:131 +0x207
github.com/buckket/go-blurhash.Encode(0x4, 0x3, {0x4dfb20, 0xc00002c2a0})
        .../poc-blurhash/vendor/github.com/buckket/go-blurhash/encode.go:63 +0x22e
main.main()
        .../poc-blurhash/main.go:23 +0xc9
exit status 2
@buckket buckket self-assigned this Oct 9, 2023
@buckket buckket added the bug Something isn't working label Oct 9, 2023
@buckket
Copy link
Owner

buckket commented Oct 9, 2023

Thanks for reporting! I suspect the problem is within the golang.org/x/image/tiff decoder though. The library itself is not using any 3rd party library or decoder, it just requires a valid image.Image, which seems the malformed here.

@jswright
Copy link

I suspect the problem is within the golang.org/x/image/tiff decoder though.

Agreed - see golang/go#67624.

@hedhyw hedhyw closed this as completed Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants