2005-04-25 Lutz Mueller <lutz@users.sourceforge.net>
authorLutz Mueller <lutz.s.mueller@gmail.com>
Mon, 25 Apr 2005 21:06:20 +0000 (23:06 +0200)
committerLutz Mueller <lutz.s.mueller@gmail.com>
Mon, 25 Apr 2005 21:06:20 +0000 (23:06 +0200)
* libexif/exif-data.c (exif_entry_fix): '\0...' as USER_COMMENT is ok, too.

ChangeLog
libexif/exif-entry.c

index e98d1ce6318a239fcbf8f4ab8d1610a1c0113a69..db9cbd12ee1b036d283eb54ac1f5645d9bb90a99 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-04-25  Lutz Mueller <lutz@users.sourceforge.net>
+
+       * libexif/exif-data.c (exif_entry_fix): '\0...' as USER_COMMENT is ok, too.
+
 2005-04-25  Lutz Mueller <lutz@users.sourceforge.net>
 
        * libexif/exif-data.c: Make it compile again.
index 6dd89734d8aad0701ac24dc0308879f49557958e..c792e8cff6cd0801c9601a69476a19d795e3c2d3 100644 (file)
@@ -255,21 +255,27 @@ exif_entry_fix (ExifEntry *e)
                                exif_format_get_name (e->format));
                        e->format = EXIF_FORMAT_UNDEFINED;
                }
+
+               /* If the tag is all empty, there's nothing to do. */
+               for (i = 0; (i < e->size) && !e->data[i]; i++);
+               if (i && (i == e->size) && (i >= 8)) break;
+
                /* Some packages like Canon ZoomBrowser EX 4.5 store
                   only one zero byte followed by 7 bytes of rubbish */
                if ((e->size >= 8) && (e->data[0] == 0)) {
                        memcpy(e->data, "\0\0\0\0\0\0\0\0", 8);
                }
 
-               /*
-                * Some cameras fill the tag with '\0' or ' '. There is nothing
-                * wrong about it.
-                */
-               for (i = 0; i < e->size &&
-                           (!e->data[i] || (e->data[i] == ' ')); i++);
-               if (i && (i == e->size))
-                       exif_entry_log (e, EXIF_LOG_CODE_DEBUG,
-                               "Tag 'UserComment' is empty. This has not been changed.");
+               /* Some cameras fill the tag with ' '. This is wrong. */
+               for (i = 0; (i < e->size) && (e->data[i] == ' '); i++);
+               if (i && (i == e->size)) {
+                       exif_entry_log (e, EXIF_LOG_CODE_DEBUG, 
+                                       "The value of 'UserComment' is against specification. The value "
+                                       "has been reset.");
+                       exif_mem_free (e->priv->mem, e->data);
+                       e->data = NULL;
+                       e->size = 0;
+               }
 
                /* There need to be at least 8 bytes. */
                if (e->size < 8) {
@@ -297,7 +303,7 @@ exif_entry_fix (ExifEntry *e)
                 * afterwards, let's assume ASCII and claim the 8 first
                 * bytes for the format specifyer.
                 */
-               if (i >= 8) {
+               if (e->size >= 8) {
                        exif_entry_log (e, EXIF_LOG_CODE_DEBUG,
                                "Tag 'UserComment' did not start with "
                                "format identifyer. This has been fixed.");