fix(#2538): refuse a JSON parametric curve without exactly its parameters - #2543
Merged
Conversation
colourbill-ctrl
requested review from
ChrisCoxArt,
maxderhak and
xsscx
as code owners
September 13, 2026 02:25
This was referenced Sep 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2538.
The problem
CIccTagJsonParametricCurve::ParseJson()accepted a parametric curve that supplied fewer parameters than its function type requires, and returned true with the rest ofm_dParamuninitialised.SetFunctionType()allocatesm_dParamwith a barenew[]and fills nothing; the reader wrote only min(supplied, required) entries, and none at all whenparamswas missing or not an array.Write()then encoded whatever the heap held.There were two ways in:
paramsfunctionType4,params[2.4]functionTypeoutside 16 bitsint(no case, count 0) whileSetFunctionType()got the value narrowed to 4It also silently truncated a longer array.
The XML twin,
CIccTagXmlParametricCurve::ParseXml(), has required the exact count since the 2015 import and has bounded the function type since #1851. On the same build,iccFromXmlwrites no profile for the short, empty, long and 65540 variants. The binaryRead()fills every parameter.The change
functionTypeis read asicUInt16Number.jsonToValuerange-checks the conversion, so a value that does not fit the field is refused.GetNumParam(), soSetFunctionType()'s table is the only one. The count enforced is, by construction, the size of the allocation.paramsmust be an array of exactly that count, matching XML. A longer array is now refused.iccToJsonalways emits exactlyGetNumParam()values, and no tracked JSON carries a parametric curve.Tests
New:
.github/ci/regression/parametric-curve-params-json.cpp→iccdev.parametric-curve-params-json. It drives the reader directly and asserts both the return value and every parameter of each accepted curve. Neither depends on heap contents, so the red shows on a plain build.fb5f65d0, exactly the 7 refusal cases fail, each observing true.!=→<on the count fails only the eight-parameter case. Restoring theintread fails only the 65540 and -65532 cases.The maintainer's Valgrind path, with the short-params document from the issue,
valgrind --track-origins=yes --error-exitcode=86:fb5f65d0, ReleaseCIccTagParametricCurve::Apply←Validate5c48c565, ReleasePre-flight
All measured on the commit this PR carries.
iccdev.spectral-tiff-preview, which needs a localimagecodecsPython module-L json-WerrorThe full strict builds were killed by the local harness's memory guard, so the strict evidence covers the changed library and its tools, not every target. Dispatched
ci-pr-actionwithci_scope=sourcebefore opening: run 34732433437 concluded success, 14 jobs green and 2 skipped by design.iccdev.parametric-curve-params-jsonis logged Passed in GCC Strict ASAN+UBSAN Debug (job 103657605039), Windows MSVC (103657605001) and Windows ClangCL (103657604974). The GCC 15.2 LTO and macOS jobs are green but log no CTest line for it.Not in this diff, noted only: a float
functionTypesuch as 4.7 is read as 4, and parameters pass through a double to float cast.