PR #25979 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25979
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25979.patch


>From 51a664711a34aeef6d2a7d263af2a3793865eb4a Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Thu, 12 Nov 2026 05:48:25 +0100
Subject: [PATCH 1/3] avfilter/vf_fftdnoiz: keep the mirrored block edges
 inside the plane

Fixes: out of array read
Fixes: m6tY8nWPDbId
Out of array read Replicated through UnModified FFmpeg with ASAN
Regression since: 30a49a5230

Based on a patch by lusoris, which clamped the index instead.
Found-by: lusoris
---
 libavfilter/vf_fftdnoiz.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/libavfilter/vf_fftdnoiz.c b/libavfilter/vf_fftdnoiz.c
index 66a889776ab..afddc212490 100644
--- a/libavfilter/vf_fftdnoiz.c
+++ b/libavfilter/vf_fftdnoiz.c
@@ -20,6 +20,7 @@
 
 #include "libavutil/common.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/internal.h"
 #include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
@@ -80,7 +81,7 @@ typedef struct FFTdnoizContext {
     av_tx_fn tx_fn, itx_fn;
     av_tx_fn tx_r_fn, itx_r_fn;
 
-    void (*import_row)(AVComplexFloat *dst, uint8_t *src, int rw, float scale, 
float *win, int off);
+    void (*import_row)(AVComplexFloat *dst, uint8_t *src, int rw, float scale, 
float *win, int off, int last);
     void (*export_row)(AVComplexFloat *src, uint8_t *dst, int rw, int depth, 
float *win);
 } FFTdnoizContext;
 
@@ -146,11 +147,16 @@ typedef struct ThreadData {
 } ThreadData;
 
 static void import_row8(AVComplexFloat *dst, uint8_t *src, int rw,
-                        float scale, float *win, int off)
+                        float scale, float *win, int off, int last)
 {
-    for (int j = 0; j < rw; j++) {
-        const int i = abs(j + off);
-        dst[j].re = src[i] * scale * win[j];
+    const int mirrored = FFMIN(-off, rw);
+
+    for (int j = 0; j < mirrored; j++) {
+        dst[j].re = src[avpriv_mirror(j + off, last)] * scale * win[j];
+        dst[j].im = 0.f;
+    }
+    for (int j = mirrored; j < rw; j++) {
+        dst[j].re = src[j + off] * scale * win[j];
         dst[j].im = 0.f;
     }
 }
@@ -162,13 +168,18 @@ static void export_row8(AVComplexFloat *src, uint8_t 
*dst, int rw, int depth, fl
 }
 
 static void import_row16(AVComplexFloat *dst, uint8_t *srcp, int rw,
-                         float scale, float *win, int off)
+                         float scale, float *win, int off, int last)
 {
     uint16_t *src = (uint16_t *)srcp;
 
-    for (int j = 0; j < rw; j++) {
-        const int i = abs(j + off);
-        dst[j].re = src[i] * scale * win[j];
+    const int mirrored = FFMIN(-off, rw);
+
+    for (int j = 0; j < mirrored; j++) {
+        dst[j].re = src[avpriv_mirror(j + off, last)] * scale * win[j];
+        dst[j].im = 0;
+    }
+    for (int j = mirrored; j < rw; j++) {
+        dst[j].re = src[j + off] * scale * win[j];
         dst[j].im = 0;
     }
 }
@@ -301,9 +312,9 @@ static void import_block(FFTdnoizContext *s,
     buffer_linesize /= sizeof(float);
 
     for (int i = 0; i < rh; i++) {
-        uint8_t *src = srcp + src_linesize * abs(y * size + i + hoff) + x * 
size * bpp;
+        uint8_t *src = srcp + src_linesize * avpriv_mirror(y * size + i + 
hoff, height - 1) + x * size * bpp;
 
-        s->import_row(dst, src, rw, scale, s->win[i], woff);
+        s->import_row(dst, src, rw, scale, s->win[i], woff, width - 1 - x * 
size);
         for (int j = rw; j < block; j++) {
             dst[j].re = dst[rw - 1].re;
             dst[j].im = 0.f;
-- 
2.54.0


>From 24b52b77300403b8e91e1a4a41cb67d5a1197793 Mon Sep 17 00:00:00 2001
From: Ratnaker Gautam <[email protected]>
Date: Sun, 8 Nov 2026 16:46:04 +0100
Subject: [PATCH 2/3] avcodec/vmdvideo: reject method 2 frames shorter than the
 frame area

A method 2 frame with too little data was returned with the part of the
frame past the end of the data left as it was in the reused frame
buffer, exposing previously decoded pictures.

Fixes: information disclosure
Fixes: 4q1titS5dliF
Information disclosure Replicated through UnModified FFmpeg

Found-by: Ratnaker Gautam
---
 libavcodec/vmdvideo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vmdvideo.c b/libavcodec/vmdvideo.c
index b168a931ce3..022e60a6927 100644
--- a/libavcodec/vmdvideo.c
+++ b/libavcodec/vmdvideo.c
@@ -325,7 +325,9 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
 
     case 2:
         for (i = 0; i < frame_height; i++) {
-            bytestream2_get_buffer(&gb, dp, frame_width);
+            if (bytestream2_get_bytes_left(&gb) < frame_width)
+                return AVERROR_INVALIDDATA;
+            bytestream2_get_bufferu(&gb, dp, frame_width);
             dp += frame->linesize[0];
         }
         break;
-- 
2.54.0


>From 774680d12f1285520994805261aa2c280caf796b Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sun, 8 Nov 2026 16:47:11 +0100
Subject: [PATCH 3/3] avcodec/vmdvideo: reject frames with an unknown rendering
 method

Fixes: information disclosure
Fixes: gwIoY2z5dNBe
Information disclosure Replicated through UnModified FFmpeg

Found during triage of the security report 4q1titS5dliF
---
 libavcodec/vmdvideo.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/vmdvideo.c b/libavcodec/vmdvideo.c
index 022e60a6927..a9f73389af3 100644
--- a/libavcodec/vmdvideo.c
+++ b/libavcodec/vmdvideo.c
@@ -372,6 +372,9 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
             pp  = FF_PTR_ADD(pp, prev_linesize);
         }
         break;
+    default:
+        avpriv_request_sample(s->avctx, "Method %d", meth);
+        return AVERROR_PATCHWELCOME;
     }
     return 0;
 }
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to