dsoprea / go-jpeg-image-structure

Parse JPEG data into segments via code or CLI from pure Go. Read/export/write EXIF data. Read XMP and IPTC metadata.
MIT License
70 stars 21 forks source link

Error when parsing image with empty E1 marker #16

Open anantadwi13 opened 2 years ago

anantadwi13 commented 2 years ago

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) 
}
tsmethurst commented 2 years ago

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

anantadwi13 commented 2 years ago

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
)
startled-cat commented 3 days ago

I ran into the same issue recently, is there any chance of merging this PR? @dsoprea