Mercurial > hg > openjdk > lambda > jdk
changeset 10224:ccca37ca416a
8014098: Better profile validation
Reviewed-by: bae, mschoene, prr
author | jchen |
---|---|
date | Thu, 13 Jun 2013 12:14:37 -0700 |
parents | 6d9ec6877a7f |
children | 5a14ecd30b4e |
files | src/share/native/sun/java2d/cmm/lcms/cmsio0.c |
diffstat | 1 files changed, 24 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/native/sun/java2d/cmm/lcms/cmsio0.c Thu Jun 13 10:31:21 2013 +0800 +++ b/src/share/native/sun/java2d/cmm/lcms/cmsio0.c Thu Jun 13 12:14:37 2013 -0700 @@ -1074,6 +1074,27 @@ } +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 static @@ -1087,6 +1108,7 @@ cmsTagTypeSignature TypeBase; cmsTagTypeHandler* TypeHandler; + if (!SanityCheck(FileOrig)) return FALSE; for (i=0; i < Icc -> TagCount; i++) { @@ -1292,8 +1314,8 @@ // Should we just calculate the needed space? if (MemPtr == NULL) { - *BytesNeeded = cmsSaveProfileToIOhandler(hProfile, NULL); - return TRUE; + *BytesNeeded = cmsSaveProfileToIOhandler(hProfile, NULL); + return (*BytesNeeded == 0 ? FALSE : TRUE); } // That is a real write operation