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
e2d1eace
Commit
e2d1eace
authored
Nov 19, 2011
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adx: validate header values
parent
8db67610
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
adxdec.c
libavcodec/adxdec.c
+12
-5
No files found.
libavcodec/adxdec.c
View file @
e2d1eace
...
...
@@ -93,7 +93,7 @@ static void adx_decode_stereo(int16_t *out,const uint8_t *in,
* @param avctx codec context
* @param buf packet data
* @param bufsize packet size
* @return data offset or
0
if header is invalid
* @return data offset or
negative error code
if header is invalid
*/
static
int
adx_decode_header
(
AVCodecContext
*
avctx
,
const
uint8_t
*
buf
,
int
bufsize
)
...
...
@@ -101,13 +101,18 @@ static int adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
int
offset
;
if
(
buf
[
0
]
!=
0x80
)
return
0
;
return
AVERROR_INVALIDDATA
;
offset
=
(
AV_RB32
(
buf
)
^
0x80000000
)
+
4
;
if
(
bufsize
<
offset
||
memcmp
(
buf
+
offset
-
6
,
"(c)CRI"
,
6
))
return
0
;
return
AVERROR_INVALIDDATA
;
avctx
->
channels
=
buf
[
7
];
if
(
avctx
->
channels
>
2
)
return
AVERROR_INVALIDDATA
;
avctx
->
sample_rate
=
AV_RB32
(
buf
+
8
);
if
(
avctx
->
sample_rate
<
1
||
avctx
->
sample_rate
>
INT_MAX
/
(
avctx
->
channels
*
18
*
8
))
return
AVERROR_INVALIDDATA
;
avctx
->
bit_rate
=
avctx
->
sample_rate
*
avctx
->
channels
*
18
*
8
/
32
;
return
offset
;
...
...
@@ -125,8 +130,10 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
if
(
!
c
->
header_parsed
)
{
int
hdrsize
=
adx_decode_header
(
avctx
,
buf
,
rest
);
if
(
!
hdrsize
)
return
-
1
;
if
(
hdrsize
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid stream header
\n
"
);
return
hdrsize
;
}
c
->
header_parsed
=
1
;
buf
+=
hdrsize
;
rest
-=
hdrsize
;
...
...
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