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

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new b9dcde1f88 avformat/mov: bound the iref dimg entry count by the 
sub-box size
b9dcde1f88 is described below

commit b9dcde1f88bc636b8a4b372862a01a13b3003473
Author:     Dean Ruina <[email protected]>
AuthorDate: Sat Nov 14 20:02:21 2026 +0000
Commit:     James Almer <[email protected]>
CommitDate: Sun Nov 15 23:15:13 2026 +0000

    avformat/mov: bound the iref dimg entry count by the sub-box size
    
    mov_read_iref_dimg() reads reference_count to_item_IDs without checking
    that they fit in the dimg sub-box. A box that declares more entries than
    it holds makes the demuxer read item IDs from whatever follows the
    sub-box (the next iref sub-box or the next box in meta) before
    mov_read_iref() seeks back to the end of the sub-box.
    
    The thmb/cdsc path got the same bound in dcc18b6077 (avformat/mov: bound
    the iref thmb/cdsc entry count by the sub-box size); dimg was left
    without it. Pass the sub-box size down and apply the same check.
    
    This is hardening; no memory safety issue is known to depend on it.
    
    Signed-off-by: Dean Ruina <[email protected]>
---
 libavformat/mov.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 30be8d5b67..f35334b064 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -9835,10 +9835,12 @@ fail:
     return ret;
 }
 
-static int mov_read_iref_dimg(MOVContext *c, AVIOContext *pb, int version)
+static int mov_read_iref_dimg(MOVContext *c, AVIOContext *pb, int version,
+                              uint32_t size)
 {
     HEIFItem *item = NULL;
     int entries;
+    int item_id_size = version ? 4 : 2;
     int from_item_id = version ? avio_rb32(pb) : avio_rb16(pb);
     int ret;
 
@@ -9877,6 +9879,11 @@ static int mov_read_iref_dimg(MOVContext *c, AVIOContext 
*pb, int version)
                "Derived image item references no input images\n");
         return AVERROR_INVALIDDATA;
     }
+    if ((int64_t)entries * item_id_size > (int64_t)size - item_id_size - 2) {
+        av_log(c->fc, AV_LOG_ERROR, "iref dimg entry count %d exceeds the 
sub-box size\n",
+               entries);
+        return AVERROR_INVALIDDATA;
+    }
 
     av_log(c->fc, AV_LOG_TRACE, "dimg: from_item_id %d, entries %d\n",
            from_item_id, entries);
@@ -10014,7 +10021,7 @@ static int mov_read_iref(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
         type = avio_rl32(pb);
         switch (type) {
         case MKTAG('d','i','m','g'):
-            ret = mov_read_iref_dimg(c, pb, version);
+            ret = mov_read_iref_dimg(c, pb, version, size - 8);
             if (ret < 0)
                 return ret;
             break;

-- 
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