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

Fixes: 
513469519/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SANM_fuzzer-5024854725427200
Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg


>From d5832f4fb61f6ac2504f2a0d7d8542c8ecd8c910 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sun, 31 May 2026 16:44:12 +0200
Subject: [PATCH 1/2] avcodec/sanm: reject codec47 frames taller than the
 allocated buffer

Fixes: 
513469519/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SANM_fuzzer-5024854725427200
Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavcodec/sanm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c
index ea80f60c10..ab2e878030 100644
--- a/libavcodec/sanm.c
+++ b/libavcodec/sanm.c
@@ -1563,6 +1563,9 @@ static int old_codec47(SANMVideoContext *ctx, 
GetByteContext *gb, int top, int l
     if (width > ctx->aligned_width)
         return AVERROR_INVALIDDATA;
 
+    if (FFALIGN(height, 8) > ctx->aligned_height)
+        return AVERROR_INVALIDDATA;
+
     if (bytestream2_get_bytes_left(gb) < 26)
          return AVERROR_INVALIDDATA;
 
-- 
2.52.0


>From af4b0431f086b1dff56c4cbb25ebe115cd459020 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sun, 31 May 2026 16:45:47 +0200
Subject: [PATCH 2/2] avcodec/sanm: reject codec37 frames taller than the
 allocated buffer

No testcase

Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavcodec/sanm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c
index ab2e878030..749d003a1b 100644
--- a/libavcodec/sanm.c
+++ b/libavcodec/sanm.c
@@ -1241,6 +1241,9 @@ static int old_codec37(SANMVideoContext *ctx, 
GetByteContext *gb, int top, int l
     if (width > ctx->aligned_width)
         return AVERROR_INVALIDDATA;
 
+    if (FFALIGN(height, 4) > ctx->aligned_height)
+        return AVERROR_INVALIDDATA;
+
     if (bytestream2_get_bytes_left(gb) < 16)
         return AVERROR_INVALIDDATA;
 
-- 
2.52.0

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

Reply via email to