This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch release/9.1
in repository ffmpeg.

commit d826e96263610d299487a897fe621ead8dbd10c3
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Sun Oct 25 05:48:24 2026 +0100
Commit:     Michael Niedermayer <[email protected]>
CommitDate: Sun Nov 15 06:17:20 2026 +0100

    avcodec/dovi_rpuenc: reject metadata with more extension blocks than the 
cache holds
    
    Fixes: EMtBgkYsAzTJ/testcase/dovi_ext_overflow.c
    Fixes: EMtBgkYsAzTJ
    Fixes: out of array write
    Out of array write Replicated through API with ASAN
    
    Found during the review of PR 25408.
    
    Signed-off-by: Michael Niedermayer <[email protected]>
    (cherry picked from commit 6b0b15b0d6d0344b295395fccd0db642049df20e)
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavcodec/dovi_rpuenc.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/libavcodec/dovi_rpuenc.c b/libavcodec/dovi_rpuenc.c
index 61a7702d4f..1ae4065706 100644
--- a/libavcodec/dovi_rpuenc.c
+++ b/libavcodec/dovi_rpuenc.c
@@ -650,7 +650,7 @@ int ff_dovi_rpu_generate(DOVIContext *s, const 
AVDOVIMetadata *metadata,
     const AVDOVIColorMetadata *color;
     int vdr_dm_metadata_present, vdr_rpu_id, use_prev_vdr_rpu, profile,
         buffer_size, rpu_size, pad, zero_run, dm_compression;
-    int num_ext_blocks_v1, num_ext_blocks_v2;
+    int num_ext_blocks_v1, num_ext_blocks_v2, num_static, num_dynamic;
     int dv_md_compression = s->cfg.dv_md_compression;
     uint32_t crc;
     uint8_t *dst;
@@ -743,10 +743,15 @@ int ff_dovi_rpu_generate(DOVIContext *s, const 
AVDOVIMetadata *metadata,
     }
 
     num_ext_blocks_v1 = num_ext_blocks_v2 = 0;
+    num_static = num_dynamic = 0;
     for (int i = 0; i < metadata->num_ext_blocks; i++) {
         const AVDOVIDmData *dm = av_dovi_get_ext(metadata, i);
-        if (dm_compression && ff_dovi_rpu_extension_is_static(dm->level))
-            continue;
+        if (ff_dovi_rpu_extension_is_static(dm->level)) {
+            num_static++;
+            if (dm_compression)
+                continue;
+        } else
+            num_dynamic++;
 
         switch (dm->level) {
         case 1:
@@ -771,6 +776,12 @@ int ff_dovi_rpu_generate(DOVIContext *s, const 
AVDOVIMetadata *metadata,
             return AVERROR_INVALIDDATA;
         }
     }
+    if (num_static  > FF_ARRAY_ELEMS(s->ext_blocks->dm_static) ||
+        num_dynamic > FF_ARRAY_ELEMS(s->ext_blocks->dm_dynamic)) {
+        av_log(s->logctx, AV_LOG_ERROR, "Too many ext blocks: %d static, %d 
dynamic\n",
+               num_static, num_dynamic);
+        return AVERROR_INVALIDDATA;
+    }
 
     buffer_size = 12 /* vdr seq info */ + 5 /* CRC32 + terminator */;
     buffer_size += num_ext_blocks_v1 * 13;

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to