r21678 by jghali - #14494: detect incorrect icc profiles embedded in broken JPEGs files
scribus-commit
scribus-commit at lists.scribus.net
Sun Dec 25 23:43:01 UTC 2016
Author: jghali
Date: Sun Dec 25 23:43:00 2016
New Revision: 21678
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21678
Log:
#14494: detect incorrect icc profiles embedded in broken JPEGs files
Modified:
branches/Version14x/Scribus/scribus/scimgdataloader_jpeg.cpp
Modified: branches/Version14x/Scribus/scribus/scimgdataloader_jpeg.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21678&path=/branches/Version14x/Scribus/scribus/scimgdataloader_jpeg.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/scimgdataloader_jpeg.cpp (original)
+++ branches/Version14x/Scribus/scribus/scimgdataloader_jpeg.cpp Sun Dec 25 23:43:00 2016
@@ -79,9 +79,23 @@
unsigned char* EmbedBuffer = 0;
if (read_jpeg_marker(ICC_MARKER,&cinfo, &EmbedBuffer, &EmbedLen))
{
+ bool profileIsValid = false;
QByteArray profArray = QByteArray((const char*) EmbedBuffer, EmbedLen);
ScColorProfile prof = ScColorMgmtEngine::openProfileFromMem(profArray);
if (prof)
+ {
+ // #14494: some tools out there produce broken JPEGs with inconsistent
+ // profile and image colorspaces. Check consistency, and if profile
+ // and image data are not consistent, discard embedded profile.
+ eColorSpaceType colorSpace = prof.colorSpace();
+ if (colorSpace == ColorSpace_Rgb)
+ profileIsValid = (cinfo.output_components == 3);
+ if (colorSpace == ColorSpace_Cmyk)
+ profileIsValid = (cinfo.output_components == 4);
+ if (colorSpace == ColorSpace_Gray)
+ profileIsValid = (cinfo.output_components == 1);
+ }
+ if (profileIsValid)
{
if (prof.colorSpace() == ColorSpace_Rgb)
m_profileComponents = 3;
@@ -223,22 +237,6 @@
else
m_imageInfoRecord.exifDataValid = false;
m_imageInfoRecord.exifInfo.thumbnail = QImage();
- unsigned int EmbedLen = 0;
- unsigned char* EmbedBuffer = 0;
- if (read_jpeg_marker(ICC_MARKER,&cinfo, &EmbedBuffer, &EmbedLen))
- {
- QByteArray profArray = QByteArray((const char*) EmbedBuffer, EmbedLen);
- ScColorProfile prof = ScColorMgmtEngine::openProfileFromMem(profArray);
- m_embeddedProfile = profArray;
- m_imageInfoRecord.profileName = prof.productDescription();
- m_imageInfoRecord.isEmbedded = true;
- free(EmbedBuffer);
- }
- else
- {
- m_imageInfoRecord.isEmbedded = false;
- m_imageInfoRecord.profileName = "";
- }
if (cinfo.density_unit == 0)
{
@@ -282,6 +280,37 @@
else if (cinfo.output_components == 1)
m_imageInfoRecord.colorspace = ColorSpaceGray;
m_imageInfoRecord.progressive = jpeg_has_multiple_scans(&cinfo);
+
+ unsigned int EmbedLen = 0;
+ unsigned char* EmbedBuffer = 0;
+ if (read_jpeg_marker(ICC_MARKER,&cinfo, &EmbedBuffer, &EmbedLen))
+ {
+ bool profileIsValid = false;
+ QByteArray profArray = QByteArray((const char*) EmbedBuffer, EmbedLen);
+ ScColorProfile prof = ScColorMgmtEngine::openProfileFromMem(profArray);
+ if (prof)
+ {
+ eColorSpaceType colorSpace = prof.colorSpace();
+ if (colorSpace == ColorSpace_Rgb)
+ profileIsValid = (cinfo.output_components == 3);
+ if (colorSpace == ColorSpace_Cmyk)
+ profileIsValid = (cinfo.output_components == 4);
+ if (colorSpace == ColorSpace_Gray)
+ profileIsValid = (cinfo.output_components == 1);
+ }
+ if (profileIsValid)
+ {
+ m_embeddedProfile = profArray;
+ m_imageInfoRecord.profileName = prof.productDescription();
+ }
+ m_imageInfoRecord.isEmbedded = profileIsValid;
+ free(EmbedBuffer);
+ }
+ else
+ {
+ m_imageInfoRecord.isEmbedded = false;
+ m_imageInfoRecord.profileName = "";
+ }
unsigned int PhotoshopLen = 0;
unsigned char * PhotoshopBuffer = 0;
More information about the scribus-commit
mailing list