1 Star 0 Fork 8

李宁杰/sox

forked from src-openEuler/sox 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CVE-2022-31650.patch 1.95 KB
一键复制 编辑 原始数据 按行查看 历史
From: Helmut Grohne <[email protected]>
Date: Sat, 11 Nov 2023 18:18:40 +0100
Subject: formats+aiff: reject implausibly large number of channels
Bug: https://sourceforge.net/p/sox/bugs/360/
Bug-Debian: https://bugs.debian.org/1012516
---
src/aiff.c | 5 +++++
src/formats_i.c | 10 ++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/aiff.c b/src/aiff.c
index 11ddb54..1476778 100644
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -609,6 +609,11 @@ int lsx_aiffstartwrite(sox_format_t * ft)
At 48 kHz, 16 bits stereo, this gives ~3 hours of audio.
Sorry, the AIFF format does not provide for an indefinite
number of samples. */
+ if (ft->signal.channels >= (0x7f000000 / (ft->encoding.bits_per_sample >> 3)))
+ {
+ lsx_fail_errno(ft, SOX_EOF, "too many channels for AIFF header");
+ return SOX_EOF;
+ }
return(aiffwriteheader(ft, (uint64_t) 0x7f000000 / ((ft->encoding.bits_per_sample>>3)*ft->signal.channels)));
}
diff --git a/src/formats_i.c b/src/formats_i.c
index 5e264f8..602e044 100644
--- a/src/formats_i.c
+++ b/src/formats_i.c
@@ -19,6 +19,7 @@
*/
#include "sox_i.h"
+#include <limits.h>
#include <string.h>
#include <sys/stat.h>
#include <stdarg.h>
@@ -60,9 +61,14 @@ int lsx_check_read_params(sox_format_t * ft, unsigned channels,
if (ft->seekable)
ft->data_start = lsx_tell(ft);
- if (channels && ft->signal.channels && ft->signal.channels != channels)
+ if (channels && ft->signal.channels && ft->signal.channels != channels) {
lsx_warn("`%s': overriding number of channels", ft->filename);
- else ft->signal.channels = channels;
+ } else if (channels > SHRT_MAX) {
+ lsx_fail_errno(ft, EINVAL, "implausibly large number of channels");
+ return SOX_EOF;
+ } else {
+ ft->signal.channels = channels;
+ }
if (rate && ft->signal.rate && ft->signal.rate != rate)
lsx_warn("`%s': overriding sample rate", ft->filename);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/li_ning_jie/sox.git
[email protected]:li_ning_jie/sox.git
li_ning_jie
sox
sox
master

搜索帮助