]> git.imager.perl.org - imager.git/blobdiff - imexif.c
separate no png support tests into a separate test file to avoid the
[imager.git] / imexif.c
index e3950948907a7a82e0caed790c14cb36d2517556..ff78d966cc10e8d90682dd63f5a22c66e50a65a1 100644 (file)
--- a/imexif.c
+++ b/imexif.c
@@ -229,8 +229,10 @@ static int tiff_init(imtiff *tiff, unsigned char *base, size_t length);
 static int tiff_load_ifd(imtiff *tiff, unsigned long offset);
 static void tiff_final(imtiff *tiff);
 static void tiff_clear_ifd(imtiff *tiff);
+#if 0 /* currently unused, but that may change */
 static int tiff_get_bytes(imtiff *tiff, unsigned char *to, size_t offset, 
                          size_t count);
+#endif
 static int tiff_get_tag_double(imtiff *, int index, double *result);
 static int tiff_get_tag_int(imtiff *, int index, int *result);
 static unsigned tiff_get16(imtiff *, unsigned long offset);
@@ -936,10 +938,11 @@ tiff_load_ifd(imtiff *tiff, unsigned long offset) {
     entry->tag = tiff_get16(tiff, base);
     entry->type = tiff_get16(tiff, base+2);
     entry->count = tiff_get32(tiff, base+4);
-    if (entry->type >= 1 || entry->type <= ift_last) {
+    if (entry->type >= 1 && entry->type <= ift_last) {
       entry->item_size = type_sizes[entry->type];
       entry->size = entry->item_size * entry->count;
       if (entry->size / entry->item_size != entry->count) {
+       myfree(entries);
        mm_log((1, "Integer overflow calculating tag data size processing EXIF block\n"));
        return 0;
       }
@@ -1013,7 +1016,7 @@ tiff_get_tag_double_array(imtiff *tiff, int index, double *result,
   ifd_entry *entry;
   unsigned long offset;
   if (index < 0 || index >= tiff->ifd_size) {
-    m_fatal(3, "tiff_get_tag_double_array() tag index out of range");
+    i_fatal(3, "tiff_get_tag_double_array() tag index out of range");
   }
   
   entry = tiff->ifd + index;
@@ -1077,7 +1080,7 @@ static int
 tiff_get_tag_double(imtiff *tiff, int index, double *result) {
   ifd_entry *entry;
   if (index < 0 || index >= tiff->ifd_size) {
-    m_fatal(3, "tiff_get_tag_double() index out of range");
+    i_fatal(3, "tiff_get_tag_double() index out of range");
   }
   
   entry = tiff->ifd + index;
@@ -1108,12 +1111,12 @@ tiff_get_tag_int_array(imtiff *tiff, int index, int *result, int array_index) {
   ifd_entry *entry;
   unsigned long offset;
   if (index < 0 || index >= tiff->ifd_size) {
-    m_fatal(3, "tiff_get_tag_int_array() tag index out of range");
+    i_fatal(3, "tiff_get_tag_int_array() tag index out of range");
   }
   
   entry = tiff->ifd + index;
   if (array_index < 0 || array_index >= entry->count) {
-    m_fatal(3, "tiff_get_tag_int_array() array index out of range");
+    i_fatal(3, "tiff_get_tag_int_array() array index out of range");
   }
 
   offset = entry->offset + array_index * entry->item_size;
@@ -1163,7 +1166,7 @@ static int
 tiff_get_tag_int(imtiff *tiff, int index, int *result) {
   ifd_entry *entry;
   if (index < 0 || index >= tiff->ifd_size) {
-    m_fatal(3, "tiff_get_tag_int() index out of range");
+    i_fatal(3, "tiff_get_tag_int() index out of range");
   }
 
   entry = tiff->ifd + index;
@@ -1290,7 +1293,7 @@ copy_num_array_tags(i_img *im, imtiff *tiff, tag_map *map, int map_count) {
          *workstr = '\0';
          for (j = 0; j < entry->count; ++j) {
            if (!tiff_get_tag_double_array(tiff, tag_index, &value, j)) {
-             m_fatal(3, "unexpected failure from tiff_get_tag_double_array(..., %d, ..., %d)\n", tag_index, j);
+             i_fatal(3, "unexpected failure from tiff_get_tag_double_array(..., %d, ..., %d)\n", tag_index, j);
            }
            if (j) 
              strcat(workstr, " ");
@@ -1306,7 +1309,7 @@ copy_num_array_tags(i_img *im, imtiff *tiff, tag_map *map, int map_count) {
          *workstr = '\0';
          for (j = 0; j < entry->count; ++j) {
            if (!tiff_get_tag_int_array(tiff, tag_index, &value, j)) {
-             m_fatal(3, "unexpected failure from tiff_get_tag_int_array(..., %d, ..., %d)\n", tag_index, j);
+             i_fatal(3, "unexpected failure from tiff_get_tag_int_array(..., %d, ..., %d)\n", tag_index, j);
            }
            if (j) 
              strcat(workstr, " ");
@@ -1383,7 +1386,7 @@ Retrieve a 16 bit unsigned integer from offset.
 static unsigned
 tiff_get16(imtiff *tiff, unsigned long offset) {
   if (offset + 2 > tiff->size)
-    m_fatal(3, "attempt to get16 at %uld in %uld image", offset, tiff->size);
+    i_fatal(3, "attempt to get16 at %uld in %uld image", offset, tiff->size);
 
   if (tiff->type == tt_intel) 
     return tiff->base[offset] + 0x100 * tiff->base[offset+1];
@@ -1402,7 +1405,7 @@ Retrieve a 32-bit unsigned integer from offset.
 static unsigned
 tiff_get32(imtiff *tiff, unsigned long offset) {
   if (offset + 4 > tiff->size)
-    m_fatal(3, "attempt to get16 at %uld in %uld image", offset, tiff->size);
+    i_fatal(3, "attempt to get16 at %uld in %uld image", offset, tiff->size);
 
   if (tiff->type == tt_intel) 
     return tiff->base[offset] + 0x100 * tiff->base[offset+1] 
@@ -1412,6 +1415,8 @@ tiff_get32(imtiff *tiff, unsigned long offset) {
       + 0x10000 * tiff->base[offset+1] + 0x1000000 * tiff->base[offset];
 }
 
+#if 0 /* currently unused, but that may change */
+
 /*
 =item tiff_get_bytes
 
@@ -1434,6 +1439,8 @@ tiff_get_bytes(imtiff *tiff, unsigned char *data, size_t offset,
   return 1;
 }
 
+#endif
+
 /*
 =item tiff_get16s
 
@@ -1447,7 +1454,7 @@ tiff_get16s(imtiff *tiff, unsigned long offset) {
   int result;
 
   if (offset + 2 > tiff->size)
-    m_fatal(3, "attempt to get16 at %uld in %uld image", offset, tiff->size);
+    i_fatal(3, "attempt to get16 at %uld in %uld image", offset, tiff->size);
 
   if (tiff->type == tt_intel) 
     result = tiff->base[offset] + 0x100 * tiff->base[offset+1];
@@ -1473,7 +1480,7 @@ tiff_get32s(imtiff *tiff, unsigned long offset) {
   unsigned work;
 
   if (offset + 4 > tiff->size)
-    m_fatal(3, "attempt to get16 at %uld in %uld image", offset, tiff->size);
+    i_fatal(3, "attempt to get16 at %uld in %uld image", offset, tiff->size);
 
   if (tiff->type == tt_intel) 
     work = tiff->base[offset] + 0x100 * tiff->base[offset+1] 
@@ -1501,7 +1508,7 @@ static double
 tiff_get_rat(imtiff *tiff, unsigned long offset) {
   unsigned long numer, denom;
   if (offset + 8 > tiff->size)
-    m_fatal(3, "attempt to get_rat at %lu in %lu image", offset, tiff->size);
+    i_fatal(3, "attempt to get_rat at %lu in %lu image", offset, tiff->size);
 
   numer = tiff_get32(tiff, offset);
   denom = tiff_get32(tiff, offset+4);
@@ -1525,7 +1532,7 @@ static double
 tiff_get_rats(imtiff *tiff, unsigned long offset) {
   long numer, denom;
   if (offset + 8 > tiff->size)
-    m_fatal(3, "attempt to get_rat at %lu in %lu image", offset, tiff->size);
+    i_fatal(3, "attempt to get_rat at %lu in %lu image", offset, tiff->size);
 
   numer = tiff_get32s(tiff, offset);
   denom = tiff_get32s(tiff, offset+4);