mm2 / Little-CMS

A free, open source, CMM engine. It provides fast transforms between ICC profiles.
https://www.littlecms.com
MIT License
572 stars 176 forks source link

Useful utility method #319

Closed boxerab closed 4 months ago

boxerab commented 2 years ago

sharing a useful little utility method that I use to validate the signature read from an ICC profile - with fuzzers, it's necessary to do this sanity check and reject invalid signatures.

bool isValidICCColourSpace(uint32_t signature){
    return    (signature == cmsSigXYZData ) ||
                (signature == cmsSigLabData ) ||
                (signature == cmsSigLuvData ) ||
                (signature == cmsSigYCbCrData ) ||
                (signature == cmsSigYxyData ) ||
                (signature == cmsSigRgbData ) ||
                (signature == cmsSigGrayData ) ||
                (signature == cmsSigHsvData ) ||
                (signature == cmsSigHlsData ) ||
                (signature == cmsSigCmykData ) ||
                (signature == cmsSigCmyData ) ||
                (signature == cmsSigMCH1Data ) ||
                (signature == cmsSigMCH2Data ) ||
                (signature == cmsSigMCH3Data ) ||
                (signature == cmsSigMCH4Data ) ||
                (signature == cmsSigMCH5Data ) ||
                (signature == cmsSigMCH6Data ) ||
                (signature == cmsSigMCH7Data ) ||
                (signature == cmsSigMCH8Data ) ||
                (signature == cmsSigMCH9Data ) ||
                (signature == cmsSigMCHAData ) ||
                (signature == cmsSigMCHBData ) ||
                (signature == cmsSigMCHCData ) ||
                (signature == cmsSigMCHDData ) ||
                (signature == cmsSigMCHEData ) ||
                (signature == cmsSigMCHFData ) ||
                (signature == cmsSigNamedData ) ||
                (signature == cmsSig1colorData ) ||
                (signature == cmsSig2colorData ) ||
                (signature == cmsSig3colorData ) ||
                (signature == cmsSig4colorData ) ||
                (signature == cmsSig5colorData ) ||
                (signature == cmsSig6colorData ) ||
                (signature == cmsSig7colorData ) ||
                (signature == cmsSig8colorData ) ||
                (signature == cmsSig9colorData ) ||
                (signature == cmsSig10colorData ) ||
                (signature == cmsSig11colorData ) ||
                (signature == cmsSig12colorData ) ||
                (signature == cmsSig13colorData ) ||
                (signature == cmsSig14colorData ) ||
                (signature == cmsSig15colorData ) ||
                (signature == cmsSigLuvKData );
}