From: yuyong05 via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: yuyong05 <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PR] avcodec/cngdec: Fix SIGILL issue in cng_decode_frame() (PR #22300)
Date: Thu, 26 Feb 2026 21:45:41 -0000
Message-ID: <177214234206.25.18229853338689612297@29965ddac10e> (raw)
PR #22300 opened by yuyong05
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22300
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22300.patch
The issue is caused by floating-point to integer overflow conversion
at function av_clip_int16(p->filter_out[i + p->order]).
The float value is -2,441,986,048.0 out of bound, less than
INT_MIN(-2,147,483,648), which leads to UB and SIGILL crash.
- Handle NAN using isfinite()
- Clip float value into valid range of int16 with av_clipf
>From 93a0975bac8d0dc371da04195210c7cd6070646b Mon Sep 17 00:00:00 2001
From: Yong Yu <yuyong05@gmail.com>
Date: Thu, 26 Feb 2026 13:35:10 -0800
Subject: [PATCH] avcodec/cngdec: Fix SIGILL issue in cng_decode_frame()
The issue is caused by floating-point to integer overflow conversion
at function av_clip_int16(p->filter_out[i + p->order]).
The float value is -2,441,986,048.0 out of bound, less than
INT_MIN(-2,147,483,648), which leads to UB and SIGILL crash.
- Handle NAN using isfinite()
- Clip float value into valid range of int16 with av_clipf
---
libavcodec/cngdec.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libavcodec/cngdec.c b/libavcodec/cngdec.c
index eb37c33eb4..b46f5fef95 100644
--- a/libavcodec/cngdec.c
+++ b/libavcodec/cngdec.c
@@ -153,8 +153,10 @@ static int cng_decode_frame(AVCodecContext *avctx, AVFrame *frame,
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
buf_out = (int16_t *)frame->data[0];
- for (i = 0; i < avctx->frame_size; i++)
- buf_out[i] = av_clip_int16(p->filter_out[i + p->order]);
+ for (i = 0; i < avctx->frame_size; i++) {
+ const float f = p->filter_out[i + p->order];
+ buf_out[i] = !isfinite(f) ? 0 : lrintf(av_clipf(f, INT16_MIN, INT16_MAX));
+ }
memcpy(p->filter_out, p->filter_out + avctx->frame_size,
p->order * sizeof(*p->filter_out));
--
2.52.0
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2026-02-26 21:46 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=177214234206.25.18229853338689612297@29965ddac10e \
--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