8014098: Better profile validation
Reviewed-by: bae, mschoene, prr
This commit is contained in:
parent
0be0627640
commit
73c5ae165c
@ -1074,6 +1074,27 @@ cmsHPROFILE CMSEXPORT cmsOpenProfileFromMem(const void* MemPtr, cmsUInt32Number
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
cmsBool SanityCheck(_cmsICCPROFILE* profile)
|
||||||
|
{
|
||||||
|
cmsIOHANDLER* io = profile->IOhandler;
|
||||||
|
if (!io) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!io->Seek ||
|
||||||
|
!(io->Seek==NULLSeek || io->Seek==MemorySeek || io->Seek==FileSeek))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!io->Read ||
|
||||||
|
!(io->Read==NULLRead || io->Read==MemoryRead || io->Read==FileRead))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
// Dump tag contents. If the profile is being modified, untouched tags are copied from FileOrig
|
// Dump tag contents. If the profile is being modified, untouched tags are copied from FileOrig
|
||||||
static
|
static
|
||||||
@ -1087,6 +1108,7 @@ cmsBool SaveTags(_cmsICCPROFILE* Icc, _cmsICCPROFILE* FileOrig)
|
|||||||
cmsTagTypeSignature TypeBase;
|
cmsTagTypeSignature TypeBase;
|
||||||
cmsTagTypeHandler* TypeHandler;
|
cmsTagTypeHandler* TypeHandler;
|
||||||
|
|
||||||
|
if (!SanityCheck(FileOrig)) return FALSE;
|
||||||
|
|
||||||
for (i=0; i < Icc -> TagCount; i++) {
|
for (i=0; i < Icc -> TagCount; i++) {
|
||||||
|
|
||||||
@ -1292,8 +1314,8 @@ cmsBool CMSEXPORT cmsSaveProfileToMem(cmsHPROFILE hProfile, void *MemPtr, cmsUIn
|
|||||||
// Should we just calculate the needed space?
|
// Should we just calculate the needed space?
|
||||||
if (MemPtr == NULL) {
|
if (MemPtr == NULL) {
|
||||||
|
|
||||||
*BytesNeeded = cmsSaveProfileToIOhandler(hProfile, NULL);
|
*BytesNeeded = cmsSaveProfileToIOhandler(hProfile, NULL);
|
||||||
return TRUE;
|
return (*BytesNeeded == 0 ? FALSE : TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// That is a real write operation
|
// That is a real write operation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user