From: thomasdullien via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: thomasdullien <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] swscale/yuv2rgb: fix out-of-bounds access with odd srcSliceH in YUV422 (PR #20883)
Date: Mon, 10 Nov 2025 09:34:26 -0000
Message-ID: <176276726662.25.17844784980744310524@2cb04c0e5124> (raw)
PR #20883 opened by thomasdullien
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20883
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20883.patch
For transparency: I am experimenting with an AI-assisted patch process, where the AI agent attempts to help
root-cause analyze a crash by means of reproducing the crash with ASAN, making a recording with 'rr', and
documenting the analysis at a granular level with verbatim quotes from the 'rr' trace. This root-cause analysis
is then iteratively reviewed (e.g. as a human reviewer I check it for accuracy and plausibility) before a patch is
generated. The process generates a detailed analysis report, an 'rr' trace that can be shared with other to help
with the verification, and a patch. Given that it is unlear how to best share the 'rr' trace, I have only attached the
detailed root-cause analysis document that was at the end of the iterative process.
Tests have been run and pass.
=== Description ===
The YUV422 conversion functions process 2 rows at once but did not
check whether a second row actually exists when srcSliceH is odd.
With bottom-to-top processing (negative strides), this caused
pu_2/pv_2 pointers to be set before the buffer start, leading to
out-of-bounds memory access when accessing pu_2[0] or pv_2[0].
This patch adds a check to skip row 2 processing in the final
remainder section when srcSliceH is odd, preventing access to
non-existent rows while still processing all available source lines.
Performance impact is minimal: one bitwise AND operation only in the
remainder section (when width is not divisible by 4), so performance
regression is unlikely to be severe.
Fixes: https://trac.ffmpeg.org/ticket/11691
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
From 95b96efa7bc7b587e857b3e780d72b1192cb6a49 Mon Sep 17 00:00:00 2001
From: Thomas Dullien <thomas.dullien@gmail.com>
Date: Sun, 9 Nov 2025 12:16:27 +0100
Subject: [PATCH] swscale/yuv2rgb: fix out-of-bounds access with odd srcSliceH
in YUV422
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The YUV422 conversion functions process 2 rows at once but did not
check whether a second row actually exists when srcSliceH is odd.
With bottom-to-top processing (negative strides), this caused
pu_2/pv_2 pointers to be set before the buffer start, leading to
out-of-bounds memory access when accessing pu_2[0] or pv_2[0].
This patch adds a check to skip row 2 processing in the final
remainder section when srcSliceH is odd, preventing access to
non-existent rows while still processing all available source lines.
Performance impact is minimal: one bitwise AND operation only in the
remainder section (when width is not divisible by 4), so performance
regression is unlikely to be severe.
Fixes: https://trac.ffmpeg.org/ticket/11691
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---
libswscale/yuv2rgb.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c
index 48089760f5..cb5bcfaac2 100644
--- a/libswscale/yuv2rgb.c
+++ b/libswscale/yuv2rgb.c
@@ -364,8 +364,10 @@ const int *sws_getCoefficients(int colorspace)
LOADCHROMA(1, 0); \
PUTFUNC(1, 0, 0); \
\
- LOADCHROMA(2, 0); \
- PUTFUNC(2, 0, 0 + 8); \
+ if (!(srcSliceH & 1)) { \
+ LOADCHROMA(2, 0); \
+ PUTFUNC(2, 0, 0 + 8); \
+ } \
ENDYUV2RGBFUNC()
#define LOADDITHER16 \
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2025-11-10 9:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=176276726662.25.17844784980744310524@2cb04c0e5124 \
--to=ffmpeg-devel@ffmpeg.org \
--cc=code@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git