go-jpeg-image-structure icon indicating copy to clipboard operation
go-jpeg-image-structure copied to clipboard

Error when parsing image with empty E1 marker

Open anantadwi13 opened this issue 4 years ago • 3 comments

I have a problem when parsing an image with an empty marker (marker length is only 2 bytes 0xFFE10002). I don't know how the image was created. But this make my program return in the failed state. If I tried to check the image from other exif tools, they would run fine. So, I just want to know. Why did you put this l <= 2 instead of l < 2? What is the consideration? Can I make a PR to change it? Thank you.

From : https://github.com/dsoprea/go-jpeg-image-structure/blob/b434301c683610a9218386e4dada79e03b7aadef/v2/splitter.go#L235-L236

To :

 if l < 2 { 
 	log.Panicf("length of size read for non-special marker (%02x) is unexpectedly not more than or equal to two.", markerId) 
}

anantadwi13 avatar Feb 12 '22 22:02 anantadwi13

Just discovered the same issue when using the library myself. Did you find a workaround?

tsmethurst avatar Mar 21 '22 15:03 tsmethurst

Hi @tsmethurst, please check my latest PR. Currently I'm using it. If you have a problem with importing the code, you have to replace your dependency in go.mod. For example:

require (
    github.com/dsoprea/go-jpeg-image-structure v0.0.0-20210512043942-b434301c6836
)

replace (
    github.com/dsoprea/go-jpeg-image-structure v0.0.0-20210512043942-b434301c6836 => github.com/anantadwi13/go-jpeg-image-structure v0.0.0-20220321163928-132a9008440e
)

anantadwi13 avatar Mar 21 '22 17:03 anantadwi13