Skip to content
Permalink
Browse files Browse the repository at this point in the history
Changed the JPEG writer to raise a warning when the exif profile exce…
…eds 65533 bytes and truncate it.
  • Loading branch information
dlemstra committed Aug 13, 2016
1 parent 0c5b13b commit 9e187b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions coders/jpeg.c
Expand Up @@ -1918,10 +1918,15 @@ static void WriteProfile(j_compress_ptr jpeg_info,Image *image)
profile=GetImageProfile(image,name);
p=GetStringInfoDatum(custom_profile);
if (LocaleCompare(name,"EXIF") == 0)
for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=65533L)
{
length=MagickMin(GetStringInfoLength(profile)-i,65533L);
jpeg_write_marker(jpeg_info,XML_MARKER,GetStringInfoDatum(profile)+i,
length=GetStringInfoLength(profile);
if (length > 65533L)
{
(void) ThrowMagickException(&image->exception,GetMagickModule(),
CoderWarning,"ExifProfileSizeExceedsLimit",image->filename);
length=65533L;
}
jpeg_write_marker(jpeg_info,XML_MARKER,GetStringInfoDatum(profile),
(unsigned int) length);
}
if (LocaleCompare(name,"ICC") == 0)
Expand Down
3 changes: 3 additions & 0 deletions config/english.xml
Expand Up @@ -205,6 +205,9 @@
</message>
</error>
<warning>
<message name="ExifProfileSizeExceedsLimit">
exif profile size exceeds limit and will be truncated
</message>
<message name="LosslessToLossyJPEGConversion">
lossless to lossy JPEG conversion
</message>
Expand Down

0 comments on commit 9e187b7

Please sign in to comment.