Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
83613154
Commit
83613154
authored
Mar 25, 2011
by
Reimar Döffinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DPX decode: add buffer size checks.
parent
f55dd6c6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
dpx.c
libavcodec/dpx.c
+14
-5
No files found.
libavcodec/dpx.c
View file @
83613154
...
...
@@ -68,6 +68,11 @@ static int decode_frame(AVCodecContext *avctx,
unsigned
int
rgbBuffer
;
if
(
avpkt
->
size
<=
0x324
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Packet too small for DPX header
\n
"
);
return
AVERROR_INVALIDDATA
;
}
magic_num
=
AV_RB32
(
buf
);
buf
+=
4
;
...
...
@@ -83,6 +88,10 @@ static int decode_frame(AVCodecContext *avctx,
}
offset
=
read32
(
&
buf
,
endian
);
if
(
avpkt
->
size
<=
offset
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Invalid data start offset
\n
"
);
return
AVERROR_INVALIDDATA
;
}
// Need to end in 0x304 offset from start of file
buf
=
avpkt
->
data
+
0x304
;
w
=
read32
(
&
buf
,
endian
);
...
...
@@ -122,7 +131,7 @@ static int decode_frame(AVCodecContext *avctx,
case
10
:
avctx
->
pix_fmt
=
PIX_FMT_RGB48
;
target_packet_size
=
6
;
source_packet_size
=
elements
*
2
;
source_packet_size
=
4
;
break
;
case
12
:
case
16
:
...
...
@@ -156,6 +165,10 @@ static int decode_frame(AVCodecContext *avctx,
ptr
=
p
->
data
[
0
];
stride
=
p
->
linesize
[
0
];
if
(
source_packet_size
*
avctx
->
width
*
avctx
->
height
>
buf_end
-
buf
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Overread buffer. Invalid header?
\n
"
);
return
-
1
;
}
switch
(
bits_per_color
)
{
case
10
:
for
(
x
=
0
;
x
<
avctx
->
height
;
x
++
)
{
...
...
@@ -173,10 +186,6 @@ static int decode_frame(AVCodecContext *avctx,
case
8
:
case
12
:
// Treat 12-bit as 16-bit
case
16
:
if
(
source_packet_size
*
avctx
->
width
*
avctx
->
height
>
buf_end
-
buf
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Overread buffer. Invalid header?
\n
"
);
return
-
1
;
}
if
(
source_packet_size
==
target_packet_size
)
{
for
(
x
=
0
;
x
<
avctx
->
height
;
x
++
)
{
memcpy
(
ptr
,
buf
,
target_packet_size
*
avctx
->
width
);
...
...
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