Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
itdan3344
stb
提交
2073403a
S
stb
项目概览
itdan3344
/
stb
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
stb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2073403a
编写于
11月 08, 2015
作者:
S
Sean Barrett
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix two setup crashes found by fuzz testing
上级
297ff628
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
19 deletion
+29
-19
stb_vorbis.c
stb_vorbis.c
+28
-18
tests/test_vorbis.c
tests/test_vorbis.c
+1
-1
未找到文件。
stb_vorbis.c
浏览文件 @
2073403a
...
...
@@ -556,9 +556,11 @@ enum STBVorbisError
#if !(defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh))
#include <malloc.h>
#endif
#else
#else
// STB_VORBIS_NO_CRT
#define NULL 0
#endif
#endif // STB_VORBIS_NO_CRT
#include <limits.h>
#if !defined(_MSC_VER) && !(defined(__MINGW32__) && defined(__forceinline))
#if __GNUC__
...
...
@@ -3645,14 +3647,15 @@ static int start_decoder(vorb *f)
get32
(
f
);
// bitrate_nominal
get32
(
f
);
// bitrate_minimum
x
=
get8
(
f
);
{
int
log0
,
log1
;
log0
=
x
&
15
;
log1
=
x
>>
4
;
f
->
blocksize_0
=
1
<<
log0
;
f
->
blocksize_1
=
1
<<
log1
;
if
(
log0
<
6
||
log0
>
13
)
return
error
(
f
,
VORBIS_invalid_setup
);
if
(
log1
<
6
||
log1
>
13
)
return
error
(
f
,
VORBIS_invalid_setup
);
if
(
log0
>
log1
)
return
error
(
f
,
VORBIS_invalid_setup
);
{
int
log0
,
log1
;
log0
=
x
&
15
;
log1
=
x
>>
4
;
f
->
blocksize_0
=
1
<<
log0
;
f
->
blocksize_1
=
1
<<
log1
;
if
(
log0
<
6
||
log0
>
13
)
return
error
(
f
,
VORBIS_invalid_setup
);
if
(
log1
<
6
||
log1
>
13
)
return
error
(
f
,
VORBIS_invalid_setup
);
if
(
log0
>
log1
)
return
error
(
f
,
VORBIS_invalid_setup
);
}
// framing_flag
...
...
@@ -3828,6 +3831,7 @@ static int start_decoder(vorb *f)
}
else
{
c
->
lookup_values
=
c
->
entries
*
c
->
dimensions
;
}
if
(
c
->
lookup_values
==
0
)
return
error
(
f
,
VORBIS_invalid_setup
);
mults
=
(
uint16
*
)
setup_temp_malloc
(
f
,
sizeof
(
mults
[
0
])
*
c
->
lookup_values
);
if
(
mults
==
NULL
)
return
error
(
f
,
VORBIS_outofmem
);
for
(
j
=
0
;
j
<
(
int
)
c
->
lookup_values
;
++
j
)
{
...
...
@@ -3848,21 +3852,27 @@ static int start_decoder(vorb *f)
if
(
c
->
multiplicands
==
NULL
)
{
setup_temp_free
(
f
,
mults
,
sizeof
(
mults
[
0
])
*
c
->
lookup_values
);
return
error
(
f
,
VORBIS_outofmem
);
}
len
=
sparse
?
c
->
sorted_entries
:
c
->
entries
;
for
(
j
=
0
;
j
<
len
;
++
j
)
{
int
z
=
sparse
?
c
->
sorted_values
[
j
]
:
j
,
div
=
1
;
unsigned
int
z
=
sparse
?
c
->
sorted_values
[
j
]
:
j
;
unsigned
int
div
=
1
;
for
(
k
=
0
;
k
<
c
->
dimensions
;
++
k
)
{
int
off
=
(
z
/
div
)
%
c
->
lookup_values
;
c
->
multiplicands
[
j
*
c
->
dimensions
+
k
]
=
#ifndef STB_VORBIS_CODEBOOK_FLOATS
mults
[
off
];
#else
mults
[
off
]
*
c
->
delta_value
+
c
->
minimum_value
;
#ifndef STB_VORBIS_CODEBOOK_FLOATS
c
->
multiplicands
[
j
*
c
->
dimensions
+
k
]
=
mults
[
off
];
#else
c
->
multiplicands
[
j
*
c
->
dimensions
+
k
]
=
mults
[
off
]
*
c
->
delta_value
+
c
->
minimum_value
;
// in this case (and this case only) we could pre-expand c->sequence_p,
// and throw away the decode logic for it; have to ALSO do
// it in the case below, but it can only be done if
// STB_VORBIS_CODEBOOK_FLOATS
// !STB_VORBIS_DIVIDES_IN_CODEBOOK
#endif
div
*=
c
->
lookup_values
;
#endif
if
(
k
+
1
<
c
->
dimensions
)
{
if
(
div
>
UINT_MAX
/
(
unsigned
int
)
c
->
lookup_values
)
{
setup_temp_free
(
f
,
mults
,
sizeof
(
mults
[
0
])
*
c
->
lookup_values
);
return
error
(
f
,
VORBIS_invalid_setup
);
}
div
*=
c
->
lookup_values
;
}
}
}
setup_temp_free
(
f
,
mults
,
sizeof
(
mults
[
0
])
*
c
->
lookup_values
);
...
...
tests/test_vorbis.c
浏览文件 @
2073403a
...
...
@@ -8,7 +8,7 @@ extern void stb_vorbis_dumpmem(void);
int
main
(
int
argc
,
char
**
argv
)
{
size_t
memlen
;
unsigned
char
*
mem
=
stb_fileu
(
"c:/x/
theme_03
.ogg"
,
&
memlen
);
unsigned
char
*
mem
=
stb_fileu
(
"c:/x/
vorbis/1
.ogg"
,
&
memlen
);
int
chan
,
samplerate
;
short
*
output
;
int
samples
=
stb_vorbis_decode_memory
(
mem
,
memlen
,
&
chan
,
&
samplerate
,
&
output
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录