diff mbox series

[FFmpeg-devel,1/2] avcodec/hevc_mp4toannexb_bsf: Check nalu_size

Message ID 20200419222122.7020-1-michael@niedermayer.cc
State Accepted
Commit ae2537f53e8ebfa36345241b5b70c0b1aef66dd2
Headers show
Series [FFmpeg-devel,1/2] avcodec/hevc_mp4toannexb_bsf: Check nalu_size
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Michael Niedermayer April 19, 2020, 10:21 p.m. UTC
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>
---
 libavcodec/hevc_mp4toannexb_bsf.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Michael Niedermayer April 23, 2020, 5:22 p.m. UTC | #1
On Mon, Apr 20, 2020 at 12:21:21AM +0200, Michael Niedermayer wrote:
> 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>
> ---
>  libavcodec/hevc_mp4toannexb_bsf.c | 5 +++++
>  1 file changed, 5 insertions(+)

will apply


[...]
diff mbox series

Patch

diff --git a/libavcodec/hevc_mp4toannexb_bsf.c b/libavcodec/hevc_mp4toannexb_bsf.c
index baa93628ed..30f733d775 100644
--- a/libavcodec/hevc_mp4toannexb_bsf.c
+++ b/libavcodec/hevc_mp4toannexb_bsf.c
@@ -144,6 +144,11 @@  static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out)
         for (i = 0; i < s->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 */