src/share/native/sun/java2d/cmm/lcms/cmsio0.c

Print this page

        

*** 480,489 **** --- 480,497 ---- return io -> Close(io); } // ------------------------------------------------------------------------------------------------------- + cmsIOHANDLER* CMSEXPORT cmsGetProfileIOhandler(cmsHPROFILE hProfile) + { + _cmsICCPROFILE* Icc = (_cmsICCPROFILE*)hProfile; + + if (Icc == NULL) return NULL; + return Icc->IOhandler; + } + // Creates an empty structure holding all required parameters cmsHPROFILE CMSEXPORT cmsCreateProfilePlaceholder(cmsContext ContextID) { time_t now = time(NULL); _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) _cmsMallocZero(ContextID, sizeof(_cmsICCPROFILE));
*** 649,677 **** { _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) (void*) hProfile; return _cmsSearchTag(Icc, sig, FALSE) >= 0; } ! /* ! * Enforces that the profile version is per. spec. ! * Operates on the big endian bytes from the profile. ! * Called before converting to platform endianness. ! * Byte 0 is BCD major version, so max 9. ! * Byte 1 is 2 BCD digits, one per nibble. ! * Reserved bytes 2 & 3 must be 0. ! */ ! static cmsUInt32Number _validatedVersion(cmsUInt32Number DWord) { ! cmsUInt8Number* pByte = (cmsUInt8Number*)&DWord; cmsUInt8Number temp1; cmsUInt8Number temp2; ! if (*pByte > 0x09) *pByte = (cmsUInt8Number)9; temp1 = *(pByte+1) & 0xf0; temp2 = *(pByte+1) & 0x0f; if (temp1 > 0x90) temp1 = 0x90; ! if (temp2 > 9) temp2 = 0x09; *(pByte+1) = (cmsUInt8Number)(temp1 | temp2); *(pByte+2) = (cmsUInt8Number)0; *(pByte+3) = (cmsUInt8Number)0; return DWord; --- 657,686 ---- { _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) (void*) hProfile; return _cmsSearchTag(Icc, sig, FALSE) >= 0; } ! ! ! // Enforces that the profile version is per. spec. ! // Operates on the big endian bytes from the profile. ! // Called before converting to platform endianness. ! // Byte 0 is BCD major version, so max 9. ! // Byte 1 is 2 BCD digits, one per nibble. ! // Reserved bytes 2 & 3 must be 0. ! static ! cmsUInt32Number _validatedVersion(cmsUInt32Number DWord) { ! cmsUInt8Number* pByte = (cmsUInt8Number*) &DWord; cmsUInt8Number temp1; cmsUInt8Number temp2; ! if (*pByte > 0x09) *pByte = (cmsUInt8Number) 0x09; temp1 = *(pByte+1) & 0xf0; temp2 = *(pByte+1) & 0x0f; if (temp1 > 0x90) temp1 = 0x90; ! if (temp2 > 0x09) temp2 = 0x09; *(pByte+1) = (cmsUInt8Number)(temp1 | temp2); *(pByte+2) = (cmsUInt8Number)0; *(pByte+3) = (cmsUInt8Number)0; return DWord;
*** 1165,1201 **** cmsHPROFILE CMSEXPORT cmsOpenProfileFromMem(const void* MemPtr, cmsUInt32Number dwSize) { return cmsOpenProfileFromMemTHR(NULL, MemPtr, dwSize); } - static - cmsBool SanityCheck(_cmsICCPROFILE* profile) - { - cmsIOHANDLER* io; - if (!profile) { - return FALSE; - } - - 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 cmsBool SaveTags(_cmsICCPROFILE* Icc, _cmsICCPROFILE* FileOrig) { --- 1174,1184 ----
*** 1223,1233 **** if (!Data) { // Reach here if we are copying a tag from a disk-based ICC profile which has not been modified by user. // In this case a blind copy of the block data is performed ! if (SanityCheck(FileOrig) && Icc -> TagOffsets[i]) { cmsUInt32Number TagSize = FileOrig -> TagSizes[i]; cmsUInt32Number TagOffset = FileOrig -> TagOffsets[i]; void* Mem; --- 1206,1216 ---- if (!Data) { // Reach here if we are copying a tag from a disk-based ICC profile which has not been modified by user. // In this case a blind copy of the block data is performed ! if (FileOrig != NULL && Icc -> TagOffsets[i]) { cmsUInt32Number TagSize = FileOrig -> TagSizes[i]; cmsUInt32Number TagOffset = FileOrig -> TagOffsets[i]; void* Mem;
*** 1872,1882 **** return 0; } // Similar to the anterior. This function allows to write directly to the ICC profile any data, without // checking anything. As a rule, mixing Raw with cooked doesn't work, so writting a tag as raw and then reading ! // it as cooked without serializing does result into an error. If that is wha you want, you will need to dump // the profile to memry or disk and then reopen it. cmsBool CMSEXPORT cmsWriteRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, const void* data, cmsUInt32Number Size) { _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile; int i; --- 1855,1865 ---- return 0; } // Similar to the anterior. This function allows to write directly to the ICC profile any data, without // checking anything. As a rule, mixing Raw with cooked doesn't work, so writting a tag as raw and then reading ! // it as cooked without serializing does result into an error. If that is what you want, you will need to dump // the profile to memry or disk and then reopen it. cmsBool CMSEXPORT cmsWriteRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, const void* data, cmsUInt32Number Size) { _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile; int i;
*** 1896,1905 **** --- 1879,1893 ---- // Keep a copy of the block Icc ->TagPtrs[i] = _cmsDupMem(Icc ->ContextID, data, Size); Icc ->TagSizes[i] = Size; _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex); + + if (Icc->TagPtrs[i] == NULL) { + Icc->TagNames[i] = 0; + return FALSE; + } return TRUE; } // Using this function you can collapse several tag entries to the same block in the profile cmsBool CMSEXPORT cmsLinkTag(cmsHPROFILE hProfile, cmsTagSignature sig, cmsTagSignature dest)