diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2020-04-19 18:24:55 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2020-04-23 21:29:01 +0200 |
commit | a1c51c0713c11769bc64110e337a397b71df4f40 (patch) | |
tree | 4bebef68bf4ca92a3b7d351b2365551117fa7cbf | |
parent | 56774297bb5a49421d3e4d60d62371cc5a68b26a (diff) | |
download | ffmpeg-a1c51c0713c11769bc64110e337a397b71df4f40.tar.gz |
avcodec/hevc_mp4toannexb_bsf: Check nalu_size
Fixes: Timeout (29sec -> 5ms)
Fixes: 20237/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_MP4TOANNEXB_fuzzer-5165615044362240
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 ae2537f53e8ebfa36345241b5b70c0b1aef66dd2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/hevc_mp4toannexb_bsf.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libavcodec/hevc_mp4toannexb_bsf.c b/libavcodec/hevc_mp4toannexb_bsf.c index 93fc5ed650..bcf845d688 100644 --- a/libavcodec/hevc_mp4toannexb_bsf.c +++ b/libavcodec/hevc_mp4toannexb_bsf.c @@ -161,6 +161,11 @@ static int hevc_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, for (i = 0; i < ctx->length_size; i++) nalu_size = (nalu_size << 8) | bytestream2_get_byte(&gb); + if (nalu_size < 2) { + ret = AVERROR_INVALIDDATA; + goto fail; + } + nalu_type = (bytestream2_peek_byte(&gb) >> 1) & 0x3f; /* prepend extradata to IRAP frames */ |