加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CVE-2021-38291.patch 1.99 KB
一键复制 编辑 原始数据 按行查看 历史
guoxiaoqi 提交于 2021-09-04 11:55 . Fix CVE-2021-3566 and CVE-2021-38291
From e01d306c647b5827102260b885faa223b646d2d1 Mon Sep 17 00:00:00 2001
From: James Almer <jamrial@gmail.com>
Date: Wed, 21 Jul 2021 01:02:44 -0300
Subject: [PATCH] avcodec/utils: don't return negative values in
av_get_audio_frame_duration()
In some extrme cases, like with adpcm_ms samples with an extremely high channel
count, get_audio_frame_duration() may return a negative frame duration value.
Don't propagate it, and instead return 0, signaling that a duration could not
be determined.
Fixes ticket #9312
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/utils.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 5fad782f5a..cfc07cbcb8 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -810,20 +810,22 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba,
int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
{
- return get_audio_frame_duration(avctx->codec_id, avctx->sample_rate,
+ int duration = get_audio_frame_duration(avctx->codec_id, avctx->sample_rate,
avctx->channels, avctx->block_align,
avctx->codec_tag, avctx->bits_per_coded_sample,
avctx->bit_rate, avctx->extradata, avctx->frame_size,
frame_bytes);
+ return FFMAX(0, duration);
}
int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes)
{
- return get_audio_frame_duration(par->codec_id, par->sample_rate,
+ int duration = get_audio_frame_duration(par->codec_id, par->sample_rate,
par->channels, par->block_align,
par->codec_tag, par->bits_per_coded_sample,
par->bit_rate, par->extradata, par->frame_size,
frame_bytes);
+ return FFMAX(0, duration);
}
#if !HAVE_THREADS
--
2.20.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化