From: Lutz M. <lu...@us...> - 2004-09-02 18:50:42
|
Update of /cvsroot/libexif/libexif/libexif In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1701/libexif Modified Files: exif-entry.c Log Message: 2004-09-02 Lutz Mueller <lu...@us...> * libexif/exif-entry.c: First part of a patch to be less strict on the USER_COMMENT-tag. Submitted by Angela Wrobel, slightly adapted. Index: exif-entry.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-entry.c,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- exif-entry.c 26 Aug 2004 20:08:09 -0000 1.55 +++ exif-entry.c 2 Sep 2004 18:50:33 -0000 1.56 @@ -336,12 +336,41 @@ case EXIF_TAG_USER_COMMENT: /* + * The specification says UNDEFINED, but some + * manufacturers don't care and use ASCII. + */ + if (e->format == EXIF_FORMAT_ASCII) { + if ((e->size <= 8) || ( + memcmp (e->data, "ASCII\0\0\0", 8) && + memcmp (e->data, "UNICODE\0", 8) && + memcmp (e->data, "JIS\0\0\0\0\0", 8) && + memcmp (e->data, "\0\0\0\0\0\0\0\0", 8))) { + snprintf (val, maxlen, _("%s (illegal " + "format ASCII, expected UNDEFINED)"), + e->data); + break; + } + } else CF (e->format, EXIF_FORMAT_UNDEFINED, val, maxlen); + + /* * According to Ralf Holzer <rh...@cm...>, * the user comment field does not have to be * NULL terminated. */ CF (e->format, EXIF_FORMAT_UNDEFINED, val, maxlen); if (e->size < 8) break; + if (!memcmp (e->data, "ASCII\0\0\0", 8)) { + strncpy (val, e->data + 8, MIN (e->size - 8, maxlen)); + break; + } + if (!memcmp (e->data, "UNICODE\0", 8)) { + strncpy (val, _("Unsupported UNICODE string"), maxlen); + break; + } + if (!memcmp (e->data, "JIS\0\0\0\0\0", 8)) { + strncpy (val, _("Unsupported JIS string"), maxlen); + break; + } strncpy (val, e->data + 8, MIN (e->size - 8, maxlen)); break; |