]> granicus.if.org Git - imagemagick/commitdiff
Skip the first 4 bytes of the exif profile since they indicate the offset to the...
authorDirk Lemstra <dirk@lemstra.org>
Tue, 27 Nov 2018 20:05:04 +0000 (21:05 +0100)
committerDirk Lemstra <dirk@lemstra.org>
Tue, 27 Nov 2018 20:07:13 +0000 (21:07 +0100)
coders/heic.c

index 2883f313b9f9d636e9803cf709e12f549a1a7166..dba94b758fb1aa9f1fdc7211acd57435db47cb26 100644 (file)
@@ -269,7 +269,7 @@ static Image *ReadHEICImage(const ImageInfo *image_info,
       size_t
         exif_size;
 
-      void
+      unsigned char
         *exif_buffer;
 
       exif_size=heif_image_handle_get_metadata_size(image_handle,exif_id);
@@ -280,8 +280,8 @@ static Image *ReadHEICImage(const ImageInfo *image_info,
           ThrowReaderException(CorruptImageError,
             "InsufficientImageDataInFile");
         }
-      exif_buffer=AcquireMagickMemory(exif_size);
-      if (exif_buffer != NULL)
+      exif_buffer=(unsigned char *) AcquireMagickMemory(exif_size);
+      if (exif_buffer !=(unsigned char *) NULL)
         {
           error=heif_image_handle_get_metadata(image_handle,
             exif_id,exif_buffer);
@@ -290,7 +290,11 @@ static Image *ReadHEICImage(const ImageInfo *image_info,
               StringInfo
                 *profile;
 
-              profile=BlobToStringInfo(exif_buffer,exif_size);
+              // The first 4 byte should be skipped since they indicate the
+              // offset to the start of the TIFF header of the Exif data.
+              profile=(StringInfo*) NULL;
+              if (exif_size > 8)
+                profile=BlobToStringInfo(exif_buffer+4,exif_size-4);
               if (profile != (StringInfo*) NULL)
                 {
                   SetImageProfile(image,"exif",profile,exception);