RFR: JDK-8347377 : Add validation checks for ICC_Profile header fields [v3]

Jayathirth D V jdv at openjdk.org
Wed Jan 15 10:53:36 UTC 2025


On Tue, 14 Jan 2025 20:45:14 GMT, Harshitha Onkar <honkar at openjdk.org> wrote:

>>> our own profiles do not strictly follow these specification, so if lcms ignores that we can do the same, especially since we fallback to the "Perceptual intent"
>>> 
>>> https://github.com/openjdk/jdk/blob/13a1775718f329b02cdeb82f9d3f7d878ac5e771/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMSTransform.java#L75
>>>the new code will be called when loading raw data for a profile, so if that profile was previously accepted and used some default values, the new code will reject it.
>> 
>> @prrace @mrserb 
>> 
>> There is difference in what is stated as accepted values for Rendering Intent in **[ICC Spec Doc](https://www.color.org/specification/ICC.1-2022-05.pdf) vs [LittleCMS API doc](https://www.littlecms.com/LittleCMS2.16%20API.pdf)**
>> 
>> **ICC Spec Doc** states Rendering Intent can take one of the following values [Pg#23]:
>> 
>> <img width="353" alt="image" src="https://github.com/user-attachments/assets/cdd62ca5-0cd0-4c2f-afa6-1777f20c643c" />
>> 
>> ----
>> **The API doc** states it can take ICC Intent as well as Non-ICC Intent values [Pg#88,90]
>> 
>> 
>> void cmsSetHeaderRenderingIntent(cmsHPROFILE hProfile,
>> cmsUInt32Number RenderingIntent);
>> 
>> Sets the profile header rendering intent. See the discussion above.
>> Parameters:
>> hProfile: Handle to a profile object
>> RenderingIntent: A cmsUInt32Number holding the intent code, as described in
>> Intents section
>> 
>> 
>> <img width="485" alt="image" src="https://github.com/user-attachments/assets/ffe5dae6-25ae-48b5-8d31-68091635e610" />
>
>> our own profiles do not strictly follow these specification, so if lcms ignores that we can do the same, especially since we fallback to the "Perceptual intent"
>> 
>> https://github.com/openjdk/jdk/blob/13a1775718f329b02cdeb82f9d3f7d878ac5e771/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMSTransform.java#L75
> 
> Is it for the above reason (it can take ICC Intent as well as Non ICC Intent) that LCMSTransform does NOT validate the value of rendering intent ?

> > The ICC spec. defines only these 4 intents, so I don't see a problem here.
> 
> our own profiles do not strictly follow these specification, so if lcms ignores that we can do the same, especially since we fallback to the "Perceptual intent"
> 
> https://github.com/openjdk/jdk/blob/13a1775718f329b02cdeb82f9d3f7d878ac5e771/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMSTransform.java#L75

I think only when user sets "Any" rendering intent we fallback to "Perceptual" intent.
@honkar-jdk What happens when we set some random intent value?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23044#discussion_r1916325457


More information about the client-libs-dev mailing list