diff mbox series

[FFmpeg-devel,2/7] avformat/bfi: Check chunk_header

Message ID 20210114225116.13486-2-michael@niedermayer.cc
State Accepted
Commit 638a151a877c27a46c15643db26c9ba726feecde
Headers show
Series [FFmpeg-devel,1/7] avformat/ads: Check size
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer Jan. 14, 2021, 10:51 p.m. UTC
Fixes: signed integer overflow: -2147483648 - 3 cannot be represented in type 'int'
Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_BFI_fuzzer-6665764123836416

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/bfi.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Michael Niedermayer Jan. 23, 2021, 12:11 a.m. UTC | #1
On Thu, Jan 14, 2021 at 11:51:11PM +0100, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -2147483648 - 3 cannot be represented in type 'int'
> Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_BFI_fuzzer-6665764123836416
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/bfi.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

[...]
diff mbox series

Patch

diff --git a/libavformat/bfi.c b/libavformat/bfi.c
index 29e2cf8cf4..2dab986f3a 100644
--- a/libavformat/bfi.c
+++ b/libavformat/bfi.c
@@ -69,6 +69,9 @@  static int bfi_read_header(AVFormatContext * s)
     /* Set the total number of frames. */
     avio_skip(pb, 8);
     chunk_header           = avio_rl32(pb);
+    if (chunk_header < 3)
+        return AVERROR_INVALIDDATA;
+
     bfi->nframes           = avio_rl32(pb);
     avio_rl32(pb);
     avio_rl32(pb);