avutil/hdr_dynamic_metadata: fix uninitialized bytes when color saturation is set without tone mapping #24590
No reviewers
Labels
No labels
avcodec
avdevice
avfilter
avformat
avutil
backport/release/4.3
backport/release/4.4
backport/release/5.0
backport/release/5.1
backport/release/6.0
backport/release/6.1
backport/release/7.0
backport/release/7.1
backport/release/8.0
backport/release/8.1
backport/release/9.0
CLI
doc
Forgejo Fairy
swresample
swscale
vulkan
API
API major
bug
enhancement
fix/bug
fix/regression
GSoC
GSoC-Qualification
help wanted
important
LGTM
meta
needs backport
needs docs
needs fate test
needs info
needs sample
needs testing
new
question
regression
repro
flaky
repro
no
repro
no(env)
repro
yes
resolution
duplicate
resolution
external
resolution
fixed
resolution
invalid
resolution
wontfix
security
No milestone
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
FFmpeg/FFmpeg!24590
Loading…
Reference in a new issue
No description provided.
Delete branch "michaelni/FFmpeg:ff-tmp-hdr10unini"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The write loop in av_dynamic_hdr_plus_to_t35() nested the
color_saturation_mapping_flag and color_saturation_weight put_bits
calls inside the tone_mapping_flag block, while the size calculation
and the parser treat these fields as unconditional per window. When
tone_mapping_flag is 0 and color_saturation_mapping_flag is 1, fewer
bits than allocated were written, leaving uninitialized heap bytes in
the returned buffer. Move the writes outside the tone_mapping_flag
block to match.
Fixes: read of uninitialized memory
Fixes: Yy1uJcbmyeBp
Fixes: AISLE-2026-0100-00011
Found-by: Joshua Rogers joshua.rogers@aisle.com
LGTM. I checked that the new test actually catches it: without the fix, window 1 comes back with the saturation flag at 0, and with the fix it matches the ref.
LLM-GPT-6-ASTRA: The fix and regression test look correct. I found no blocking issue in
4705e4d151orce77b6f53d.The saturation flag now appears once per window outside the optional tone-mapping block, with the weight still conditional on the saturation flag. This matches the size calculation and parser.
flush_put_bits()zero-pads the final partial byte; with the missing fields restored, the writer fills the advertised payload. Windows with tone mapping enabled retain the previous write order. The fixture correctly distinguishes synthetic branch coverage from Version 1 conformance: §9.4 excludes its extra window, peak-luminance matrices and saturation weight. SMPTE ST 2094-40:2020 — Dynamic Metadata for Color Volume Transform — Application #4, §§9.1 and 9.4.My verification confirms the drafts’ central results:
make -j8 fate-hdr_dynamic_metadatapasses atce77b6f53d. Restoring only the writer from the parent of4705e4d151makes window 1 decode with saturation flag 0 instead of1 weight=9/8, confirming MarcosAsh’s observation. Restoring the fix makes FATE pass again.Found-bytrailer.The drafts additionally report broader validation: GLM-5.3 reports clean Valgrind results and 20,000 randomized cases; SPACE-BUNNY-ALPHA reports 600,000 instrumented cases; GROK-4.7’s design review reports 1,920 initialization/round-trip cases. These remain attributed reports, not independently reproduced results from this combining review.
A few draft points need qualification:
master; the milestone title does not establish a different merge destination. There is no supported reason to ask for a target change.AV_HDR_PLUS_MAX_PAYLOAD_SIZE; it is not a defect in this PR.I also do not rely on SPACE-BUNNY-ALPHA’s broader claims that no in-tree producer can supply the affected combination or that this class of bug is confined to this function. The inspected parser reads the flags independently; checking this serializer and an unrelated parser does not establish a project-wide guarantee.
Classification: minor_issues_approve, solely for the optional testing follow-up; the PR can merge in its current form. This follows the supplied classification rule that non-blocking suggestions permit approval, and the Development Policy in
doc/developer.texi: testing should be adequate without being excessive, backportable bug fixes should stay focused, and security researchers should receive credit. This small bugfix satisfies those criteria and needs no external-project workaround or new FATE sample.