diff mbox series

[FFmpeg-devel,2/2] avcodec/dovi_rpudec: validate L2.ms_weight

Message ID 20240614120014.31038-2-ffmpeg@haasn.xyz
State New
Headers show
Series [FFmpeg-devel,1/2] avcodec/dovi_rpudec: add return code to parse_ext_v* | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Niklas Haas June 14, 2024, noon UTC
From: Niklas Haas <git@haasn.dev>

This is specified to be in the range -1 to 4095, apparently the only
extension level with such a restriction.
---
 libavcodec/dovi_rpudec.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/dovi_rpudec.c b/libavcodec/dovi_rpudec.c
index fc3b0a2b82..306efbb31f 100644
--- a/libavcodec/dovi_rpudec.c
+++ b/libavcodec/dovi_rpudec.c
@@ -143,6 +143,7 @@  static int parse_ext_v1(DOVIContext *s, GetBitContext *gb, AVDOVIDmData *dm)
         dm->l2.trim_chroma_weight = get_bits(gb, 12);
         dm->l2.trim_saturation_gain = get_bits(gb, 12);
         dm->l2.ms_weight = get_sbits(gb, 13);
+        VALIDATE(dm->l2.ms_weight, -1, 4095);
         break;
     case 4:
         dm->l4.anchor_pq = get_bits(gb, 12);
@@ -172,6 +173,9 @@  static int parse_ext_v1(DOVIContext *s, GetBitContext *gb, AVDOVIDmData *dm)
     }
 
     return 0;
+
+fail:
+    return AVERROR_INVALIDDATA;
 }
 
 static AVCIExy get_cie_xy(GetBitContext *gb)