Issue:
GnuPG rejecting valid JPEGs when attempting addphoto.
Findings:
photoid.c (lines 144-153) incorrectly assumes all JPEGs have a JFIF header. This
is not the case, and JPEGs can use JFIF, EXIF, both, or no header at all.
Enclosed is one such image (Sample.jpg).
Resolution:
- Either remove checking entirely (photoid.c lines 143 to 153), or
- ... Continue with the broken checking (remember that JPEGs can contain JFIF,
EXIF, both, or none), but allow the user to override:
Change from...
/* Is it a JPEG? */
if(photo[0]!=0xFF || photo[1]!=0xD8 ||
photo[6]!='J' || photo[7]!='F' || photo[8]!='I' || photo[9]!='F') { log_error(_("`%s' is not a JPEG file\n"),filename); xfree(photo); photo=NULL; xfree(filename); filename=NULL; continue; }
... to
/* Is it a JPEG? */
if(photo[0]!=0xFF || photo[1]!=0xD8 ||
photo[6]!='J' || photo[7]!='F' || photo[8]!='I' || photo[9]!='F') { tty_printf(_("`%s' does not begin with a JFIF header\n"),filename); if(!cpr_get_answer_is_yes("photoid.jpeg.jfif", _("Are you sure you want to use it? (y/N) "))) { xfree(photo); photo=NULL; xfree(filename); filename=NULL; continue; } }