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

Encoding after decoding failed: unsupported image type #55

Closed
bayandin opened this issue Aug 21, 2019 · 1 comment
Closed

Encoding after decoding failed: unsupported image type #55

bayandin opened this issue Aug 21, 2019 · 1 comment

Comments

@bayandin
Copy link
Contributor

Here is another issue I found with the help of go-fuzz:
I'm able to decode data but aren't able to encode it back.

package main

import (
	"bytes"
	"fmt"

	"github.com/pixiv/go-libjpeg/jpeg"
)

func main() {
	data := []byte("\xff\xd8\xff\xdb\x00C\x000000000000000" +
		"00000000000000000000" +
		"00000000000000000000" +
		"00000000000\xff\xc0\x00\x11\b\x00000" +
		"\x03R\"\x00G\x11\x00B\x11\x00\xff\xda\x00\f\x03R\x00G\x00B" +
		"\x00")

	img, err := jpeg.Decode(bytes.NewReader(data), &jpeg.DecoderOptions{})
	if err != nil {
		return
	}

	var w bytes.Buffer
	err = jpeg.Encode(&w, img, &jpeg.EncoderOptions{})
	if err != nil {
		panic(err)
	}
}

It prints

Invalid SOS parameters for sequential JPEG
panic: unsupported image type

I use go version go1.12.9 darwin/amd64, libjpeg-turbo 2.0.2

bayandin added a commit to bayandin/go-libjpeg that referenced this issue Aug 21, 2019
@harukasan
Copy link
Member

👍
I fixed in #57.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants