aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-12-19 00:00:40 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-10-09 22:02:20 +0200
commitc9243ed1fd3595dd629ddb98a3ac55c64ffbb35c (patch)
tree592b06ea8ff75c0396208a68920444ead4559c73
parentf9ab9bfe4ee0ee33945dc001e1ff83a93789a381 (diff)
downloadffmpeg-c9243ed1fd3595dd629ddb98a3ac55c64ffbb35c.tar.gz
avformat/nutdec: Check timebase count against main header length
Fixes: Timeout (long -> 3ms) Fixes: 28514/clusterfuzz-testcase-minimized-ffmpeg_dem_NUT_fuzzer-6078669009321984 Fixes: 30095/clusterfuzz-testcase-minimized-ffmpeg_dem_NUT_fuzzer-5074433016463360 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit c425198558826795d94af45eeb9d94e4436c9a0f) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/nutdec.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 67ccf1fe20..2ebb10ce8c 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -229,13 +229,13 @@ static int decode_main_header(NUTContext *nut)
{
AVFormatContext *s = nut->avf;
AVIOContext *bc = s->pb;
- uint64_t tmp, end;
+ uint64_t tmp, end, length;
unsigned int stream_count;
int i, j, count, ret;
int tmp_stream, tmp_mul, tmp_pts, tmp_size, tmp_res, tmp_head_idx;
- end = get_packetheader(nut, bc, 1, MAIN_STARTCODE);
- end += avio_tell(bc);
+ length = get_packetheader(nut, bc, 1, MAIN_STARTCODE);
+ end = length + avio_tell(bc);
nut->version = ffio_read_varlen(bc);
if (nut->version < NUT_MIN_VERSION &&
@@ -255,7 +255,7 @@ static int decode_main_header(NUTContext *nut)
nut->max_distance = 65536;
}
- GET_V(nut->time_base_count, tmp > 0 && tmp < INT_MAX / sizeof(AVRational));
+ GET_V(nut->time_base_count, tmp > 0 && tmp < INT_MAX / sizeof(AVRational) && tmp < length/2);
nut->time_base = av_malloc_array(nut->time_base_count, sizeof(AVRational));
if (!nut->time_base)
return AVERROR(ENOMEM);