Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
7ebdffc3
Commit
7ebdffc3
authored
Jul 28, 2016
by
Martin Storsjö
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dxv: Check to make sure we don't overrun buffers on corrupt inputs
Signed-off-by:
Martin Storsjö
<
martin@martin.st
>
parent
e328178d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
dxv.c
libavcodec/dxv.c
+11
-3
No files found.
libavcodec/dxv.c
View file @
7ebdffc3
...
...
@@ -125,7 +125,7 @@ static int dxv_decompress_dxt1(AVCodecContext *avctx)
AV_WL32
(
ctx
->
tex_data
+
4
,
bytestream2_get_le32
(
gbc
));
/* Process input until the whole texture has been filled */
while
(
pos
<
ctx
->
tex_size
/
4
)
{
while
(
pos
+
2
<=
ctx
->
tex_size
/
4
)
{
CHECKPOINT
(
2
);
/* Copy two elements from a previous offset or from the input buffer */
...
...
@@ -178,7 +178,7 @@ static int dxv_decompress_dxt5(AVCodecContext *avctx)
AV_WL32
(
ctx
->
tex_data
+
12
,
bytestream2_get_le32
(
gbc
));
/* Process input until the whole texture has been filled */
while
(
pos
<
ctx
->
tex_size
/
4
)
{
while
(
pos
+
2
<=
ctx
->
tex_size
/
4
)
{
if
(
run
)
{
run
--
;
...
...
@@ -207,7 +207,7 @@ static int dxv_decompress_dxt5(AVCodecContext *avctx)
check
+=
probe
;
}
while
(
probe
==
0xFFFF
);
}
while
(
check
&&
pos
<
ctx
->
tex_size
/
4
)
{
while
(
check
&&
pos
+
4
<=
ctx
->
tex_size
/
4
)
{
prev
=
AV_RL32
(
ctx
->
tex_data
+
4
*
(
pos
-
4
));
AV_WL32
(
ctx
->
tex_data
+
4
*
pos
,
prev
);
pos
++
;
...
...
@@ -252,6 +252,8 @@ static int dxv_decompress_dxt5(AVCodecContext *avctx)
case
2
:
/* Copy two dwords from a previous index */
idx
=
8
+
bytestream2_get_le16
(
gbc
);
if
(
idx
>
pos
||
(
unsigned
int
)(
pos
-
idx
)
+
2
>
ctx
->
tex_size
/
4
)
return
AVERROR_INVALIDDATA
;
prev
=
AV_RL32
(
ctx
->
tex_data
+
4
*
(
pos
-
idx
));
AV_WL32
(
ctx
->
tex_data
+
4
*
pos
,
prev
);
pos
++
;
...
...
@@ -274,9 +276,13 @@ static int dxv_decompress_dxt5(AVCodecContext *avctx)
}
CHECKPOINT
(
4
);
if
(
pos
+
2
>
ctx
->
tex_size
/
4
)
return
AVERROR_INVALIDDATA
;
/* Copy two elements from a previous offset or from the input buffer */
if
(
op
)
{
if
(
idx
>
pos
||
(
unsigned
int
)(
pos
-
idx
)
+
2
>
ctx
->
tex_size
/
4
)
return
AVERROR_INVALIDDATA
;
prev
=
AV_RL32
(
ctx
->
tex_data
+
4
*
(
pos
-
idx
));
AV_WL32
(
ctx
->
tex_data
+
4
*
pos
,
prev
);
pos
++
;
...
...
@@ -287,6 +293,8 @@ static int dxv_decompress_dxt5(AVCodecContext *avctx)
}
else
{
CHECKPOINT
(
4
);
if
(
op
&&
(
idx
>
pos
||
(
unsigned
int
)(
pos
-
idx
)
+
2
>
ctx
->
tex_size
/
4
))
return
AVERROR_INVALIDDATA
;
if
(
op
)
prev
=
AV_RL32
(
ctx
->
tex_data
+
4
*
(
pos
-
idx
));
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment