diff options
author | Marti Maria <marti.maria@littlecms.com> | 2022-03-06 17:54:15 +0100 |
---|---|---|
committer | Marti Maria <marti.maria@littlecms.com> | 2022-03-06 17:54:15 +0100 |
commit | 458bffeba9a74d6069659768b2c3df20a4aeb495 (patch) | |
tree | cc441bc60bc2fb71f59304c2c86f19b72e506bd7 /testbed | |
parent | a5269a91a59572478b12204c0b1ae74a5acb49c0 (diff) | |
download | lcms2-458bffeba9a74d6069659768b2c3df20a4aeb495.tar.gz |
Detect whatever a built-in has been corrupted by means of cmsWriteRawTag
Thanks to @prrace to detect such subtle bug.
cmsWriteRawTag could cause a segfault when used to corrupt a tag on a built-in profile-
Diffstat (limited to 'testbed')
-rw-r--r-- | testbed/testcms2.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/testbed/testcms2.c b/testbed/testcms2.c index a733e7e..2fea57b 100644 --- a/testbed/testcms2.c +++ b/testbed/testcms2.c @@ -8384,6 +8384,28 @@ int CheckGammaSpaceDetection(void) return 1; } +// Per issue #308. A built-in corrypted by using write raw tag was causing a segfault +static +int CheckInducedCorruption(void) +{ + cmsHTRANSFORM xform0, xform1; + char garbage[] = "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b"; + cmsHPROFILE hsrgb = cmsCreate_sRGBProfile(); + cmsHPROFILE hLab = cmsCreateLab4Profile(NULL); + + cmsSetLogErrorHandler(NULL); + cmsWriteRawTag(hsrgb, cmsSigBlueColorantTag, &garbage, sizeof(garbage)); + + xform0 = cmsCreateTransform(hsrgb, TYPE_RGB_16, hLab, TYPE_Lab_16, INTENT_RELATIVE_COLORIMETRIC, 0); + + if (xform0) cmsDeleteTransform(xform0); + + cmsCloseProfile(hsrgb); + cmsCloseProfile(hLab); + + ResetFatalError(); + return 1; +} #if 0 @@ -9414,6 +9436,7 @@ int main(int argc, char* argv[]) Check("sRGB round-trips", Check_sRGB_Rountrips); Check("Gamma space detection", CheckGammaSpaceDetection); Check("Unbounded mode w/ integer output", CheckIntToFloatTransform); + Check("Corrupted buit-in by using cmsWriteRawTag", CheckInducedCorruption); } if (DoPluginTests) |