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 48cd78bd078851a16d678a26de36693684498c22
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Sat Nov 7 22:08:08 2026 +0100
Commit:     Michael Niedermayer <[email protected]>
CommitDate: Sun Nov 15 06:17:20 2026 +0100

    swscale: reject interlaced frames whose bottom field lacks a chroma row
    
    Fixes: heap-buffer-overflow (read and write)
    Fixes: 5TZcJN8RG7oW
    
    Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24851
    
    Out of array read and write Replicated through API with ASAN
    
    (cherry picked from commit f93d46898b6a939fcc4d6a147b3c5aede82a2383)
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libswscale/swscale.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 89fb7149e8..6d28e51399 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -1509,6 +1509,12 @@ static int validate_params(SwsContext *ctx)
     return 0;
 }
 
+static int bottom_field_fits(const AVFrame *frame, const SwsFormat *field)
+{
+    const int vsub = field->desc->log2_chroma_h;
+    return 2 * AV_CEIL_RSHIFT(field->height, vsub) <= 
AV_CEIL_RSHIFT(frame->height, vsub);
+}
+
 int sws_frame_setup(SwsContext *ctx, const AVFrame *dst, const AVFrame *src)
 {
     SwsInternal *s = sws_internal(ctx);
@@ -1580,6 +1586,13 @@ int sws_frame_setup(SwsContext *ctx, const AVFrame *dst, 
const AVFrame *src)
             goto fail;
         }
 
+        if (field == FIELD_BOTTOM &&
+            (!bottom_field_fits(src, &src_fmt) || !bottom_field_fits(dst, 
&dst_fmt))) {
+            err_msg = "The bottom field has fewer chroma rows than its height 
requires";
+            ret = AVERROR(EINVAL);
+            goto fail;
+        }
+
         src_ok = ff_test_fmt(backends, &src_fmt, 0);
         dst_ok = ff_test_fmt(backends, &dst_fmt, 1);
         if ((!src_ok || !dst_ok) && !ff_fmt_equal(&src_fmt, &dst_fmt)) {

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