views:

308

answers:

2

My web app checks the first four bytes against the file extension before accepting uploaded images. A coworker showed me images from his iPhone which are being rejected. These have a different fourth byte (e1 = 225 instead of the expected e0 = 224).

Is this usual for iPhones? Are there other possible magic byte strings used in JPG files?

Edit: found this useful list: http://www.garykessler.net/library/file%5Fsigs.html

+1  A: 

They seem to indicate a sub category of JPEG in some way. What I have found out is that the FF D8 FF E0 magic indicates a "JFIF JPEG" whereas the FF D8 FF E1 indicates an "EXIF JPEG".

Edit: Found this one in a google cache: http://tinyurl.com/ydtjpjw (interesting because it indicates that Samsung has a few more variations)

Fredrik
A: 

That does appear to be a perfectly valid JPEG variant, according to Google.

Sixten Otto