Repository navigation
obs-filters: Bound .cube LUT sizes before allocating - #113
Merged
Merged
Conversation
Moves get_cube_entry, load_1d_lut, load_3d_lut and load_cube_file out of color-grade-filter.c unchanged, with enum clut_dimension, so a test can build the loader without the filter. No behavior change. Refs obs-rust#94 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Characterizes load_cube_file (1D and 3D LUTs, domain lines, missing entries) and adds regressions for LUT sizes: - LUT_1D_SIZE 1024 must load. The 1D loader sizes its buffer as 4 * width^3 halves in uint32_t, which wraps to bmalloc(0) here and crashes, so this case fails until the next commit. - sizes past the .cube spec (1D 65536, 3D 256) are refused. Refs obs-rust#94 Co-Authored-By: Claude Opus 5.5 <[email protected]>
load_1d_lut and load_3d_lut computed `4 * width * width * width` in uint32_t from an unchecked LUT_1D_SIZE/LUT_3D_SIZE. A LUT_3D_SIZE of 1024 wrapped the size to 0 (bmalloc(0) crashes), and other sizes wrapped to a small buffer that the entry loop then overran with one RGBA half per line of the file. The 1D loader also sized its buffer as width^3 entries though it only writes width, so any 1D LUT of 1024 or more entries, a common size, crashed or asked for gigabytes. - refuse LUT_1D_SIZE above 65536 and LUT_3D_SIZE above 256, the limits of the Adobe Cube LUT Specification 1.0, before allocating - size the 1D buffer as 4 * width halves - compute both sizes in size_t Fixes obs-rust#94 Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=ad5ba93b87a186699f8f2a78f4ddc4df75ea30b8 secs=339 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791667716,"gate":"rust/all/fmt","host":"linux-x86_64","key":"18bbc38449eef49a3fbb3778f08a0175e0a36480e3a80395b5437414668ae25e","lane":"lint","parents":["daddd099f8eff86f1c0567d4bb465cd6c6d7c4c7"],"secs":143,"stamp":"c754a3701c3a20e0ba40a1a55773e643","tree":"ad5ba93b87a186699f8f2a78f4ddc4df75ea30b8","v":1,"via":"run"} Ci-Attestation: {"at":1791667716,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"18bbc38449eef49a3fbb3778f08a0175e0a36480e3a80395b5437414668ae25e","lane":"lint","parents":["daddd099f8eff86f1c0567d4bb465cd6c6d7c4c7"],"secs":143,"stamp":"0716ecb230ab17eeb029ec398a2ef631","tree":"ad5ba93b87a186699f8f2a78f4ddc4df75ea30b8","v":1,"via":"run"} Ci-Attestation: {"at":1791667716,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"8665351ac9e5fb2cc6cd2a58b3cf56f0e7cc89eb6002e30c06f990c26d800d69","lane":"rust-test","parents":["daddd099f8eff86f1c0567d4bb465cd6c6d7c4c7"],"secs":43,"stamp":"113254bf42a12e86c8fe40505821674f","tree":"ad5ba93b87a186699f8f2a78f4ddc4df75ea30b8","v":1,"via":"run"} Ci-Attestation: {"at":1791667716,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"914f071c859a8f08b6bd722972d7a22652d6e16dfba8716a11e0d9698470e4bc","lane":"tier2-linux","parents":["daddd099f8eff86f1c0567d4bb465cd6c6d7c4c7"],"secs":152,"stamp":"1d3864ce4b9b4e336fdebd7e8526c7e5","tree":"ad5ba93b87a186699f8f2a78f4ddc4df75ea30b8","v":1,"via":"run"}
zackees
marked this pull request as ready for review
October 10, 2026 21:28
zackees
force-pushed
the
fix/color-grade-lut-size
branch
from
October 10, 2026 21:28
bb6fa17 to
915498c
Compare
Member
|
Rebased onto master and fixed three build problems in the earlier commits:
RED→GREEN in Tier 2: at the test commit, |
5 tasks done
5 tasks done
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.
Fixes #94.
load_1d_lut/load_3d_lutcomputed4 * width * width * widthinuint32_tfrom an uncheckedLUT_1D_SIZE/LUT_3D_SIZE, as the issue describes. The 1D path is worse than reported: it sizes its buffer aswidth³entries but only writeswidth, so ordinary 1D LUTs break:LUT_1D_SIZEbmalloc(0)→bcrashCommits
cube-lut.c, unchanged (get_cube_entry,load_1d_lut,load_3d_lut,load_cube_file,enum clut_dimension), so a test can build it without the filter. No behavior change.test/cmocka/test_cube_lut.c: 3D and 1D LUTs (values are linearized RGBA halves, alpha 1.0), domain lines, an empty domain, a missing size line, a truncated LUT; regressions:LUT_1D_SIZE 1024loads, and sizes past the spec are refused. The 1024 case crashes until the fix.LUT_1D_SIZE > 65536andLUT_3D_SIZE > 256(Adobe Cube LUT Specification 1.0) before allocating4 * widthhalvessize_tDraft because there is no C toolchain on my machine; CI is the first build of the new test target (
if(TARGET OBS::filters), compilescube-lut.cand links libobs).🤖 Generated with Claude Code