diegomura / jay-peg

Performant JPEG decoder
MIT License
7 stars 2 forks source link

Parsing fails with non-standard APP0 #9

Open wyozi opened 3 months ago

wyozi commented 3 months ago

Some JPEGs have a non-standard APP0 segment. It is non-standard but it breaks parsing because jay-peg assumes fixed size APP0.

I can't give the original image but here's the hex for the broken segment: (includes APP0 marker, two-byte size, and the whole marker data)

0xFF,0xE0,0x00,0x14,0x4A,0x46,0x49,0x46,0x00,0x01,0x01,0x01,0x01,0x2C,0x01,0x2C,0x00,0x00,0x41,0x4D,0x50,0x46

The last four bytes spell out AMPF in ascii, which according to a random googling is somehow related to some Apple extension. See also https://github.com/exiftool/exiftool/blob/master/lib/Image/ExifTool.pm#L2226