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 0bfaa06d862896365e389baa6dd2a5d19136ff7b
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Wed Nov 11 17:00:22 2026 +0100
Commit:     Michael Niedermayer <[email protected]>
CommitDate: Thu Nov 19 04:36:59 2026 +0100

    avformat/imfdec: limit the number of resources of a composition
    
    Every repetition of a resource takes an entry in the resource array of
    its track. A RepeatCount of 44000000 needed 2 GiB for it.
    
    Fixes: excessive memory allocation
    Fixes: RNdiJLvrqS9c
    
    Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25795
    
    Excessive memory allocation Replicated through UnModified FFmpeg with time 
(maximum resident set size)
    
    (cherry picked from commit fb188c15a10e498ca06de5a1568ded5d56f30674)
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavformat/imfdec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
index 2aebdc3b8b..6b4bb2ac94 100644
--- a/libavformat/imfdec.c
+++ b/libavformat/imfdec.c
@@ -77,6 +77,7 @@
 
 #define AVRATIONAL_FORMAT "%d/%d"
 #define AVRATIONAL_ARG(rational) rational.num, rational.den
+#define MAX_RESOURCES FFMIN(1 << 20, INT_MAX / 
(int)sizeof(IMFVirtualTrackResourcePlaybackCtx))
 
 /**
  * IMF Asset locator
@@ -125,6 +126,7 @@ typedef struct IMFContext {
     IMFAssetLocatorMap asset_locator_map;
     uint32_t track_count;
     IMFVirtualTrackPlaybackCtx **tracks;
+    uint32_t total_resource_count;
 } IMFContext;
 
 static int imf_uri_is_url(const char *string)
@@ -483,8 +485,9 @@ static int open_track_file_resource(AVFormatContext *s,
            asset_locator->absolute_uri);
 
     if (track_file_resource->base.repeat_count
-            > INT_MAX / sizeof(IMFVirtualTrackResourcePlaybackCtx) - 
track->resource_count)
+            > MAX_RESOURCES - c->total_resource_count)
         return AVERROR(ENOMEM);
+    c->total_resource_count += track_file_resource->base.repeat_count;
     tmp = av_fast_realloc(track->resources,
                           &track->resources_alloc_sz,
                           (track->resource_count + 
track_file_resource->base.repeat_count)

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