diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2017-06-14 16:58:20 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-06-16 01:15:51 +0200 |
commit | 31c1c0b46a7021802c3d1d18039fca30dba5a14e (patch) | |
tree | 53e1e72d20489066a6c2f775f7d40654ce986f3e | |
parent | 6d77a3ff3cd8360874d6f1787c482e09c5239511 (diff) | |
download | ffmpeg-31c1c0b46a7021802c3d1d18039fca30dba5a14e.tar.gz |
avcodec/dnxhd_parser: Do not return invalid value from dnxhd_find_frame_end() on error
Fixes: Null pointer dereference
Fixes: CVE-2017-9608
Found-by: Yihan Lian
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 611b35627488a8d0763e75c25ee0875c5b7987dd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/dnxhd_parser.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libavcodec/dnxhd_parser.c b/libavcodec/dnxhd_parser.c index 4f9bbceeeb..2519cf23c3 100644 --- a/libavcodec/dnxhd_parser.c +++ b/libavcodec/dnxhd_parser.c @@ -87,16 +87,18 @@ static int dnxhd_find_frame_end(DNXHDParserContext *dctx, dctx->w = (state >> 32) & 0xFFFF; } else if (dctx->cur_byte == 42) { int cid = (state >> 32) & 0xFFFFFFFF; + int remaining; if (cid <= 0) continue; - dctx->remaining = avpriv_dnxhd_get_frame_size(cid); - if (dctx->remaining <= 0) { - dctx->remaining = dnxhd_get_hr_frame_size(cid, dctx->w, dctx->h); - if (dctx->remaining <= 0) - return dctx->remaining; + remaining = avpriv_dnxhd_get_frame_size(cid); + if (remaining <= 0) { + remaining = dnxhd_get_hr_frame_size(cid, dctx->w, dctx->h); + if (remaining <= 0) + continue; } + dctx->remaining = remaining; if (buf_size - i >= dctx->remaining && (!dctx->interlaced || dctx->cur_field)) { int remaining = dctx->remaining; |