diff mbox series

[FFmpeg-devel,2/4] avformat/gxf: Check pkt_len

Message ID 20201027162119.19025-2-michael@niedermayer.cc
State Accepted
Commit dad9a86ca7bf912289aafb33d96980630e6ec53a
Headers show
Series [FFmpeg-devel,1/4] avformat/aiffdec: Check packet size
Related show

Checks

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

Commit Message

Michael Niedermayer Oct. 27, 2020, 4:21 p.m. UTC
Fixes: Infinite loop
Fixes: 26576/clusterfuzz-testcase-minimized-ffmpeg_dem_GXF_fuzzer-4823080360476672

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

Comments

Michael Niedermayer Nov. 4, 2020, 10:42 p.m. UTC | #1
On Tue, Oct 27, 2020 at 05:21:17PM +0100, Michael Niedermayer wrote:
> Fixes: Infinite loop
> Fixes: 26576/clusterfuzz-testcase-minimized-ffmpeg_dem_GXF_fuzzer-4823080360476672
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/gxf.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavformat/gxf.c b/libavformat/gxf.c
index 49364b7205..bbad47c240 100644
--- a/libavformat/gxf.c
+++ b/libavformat/gxf.c
@@ -285,9 +285,12 @@  static void gxf_track_tags(AVIOContext *pb, int *len, struct gxf_stream_info *si
 static void gxf_read_index(AVFormatContext *s, int pkt_len) {
     AVIOContext *pb = s->pb;
     AVStream *st;
-    uint32_t fields_per_map = avio_rl32(pb);
-    uint32_t map_cnt = avio_rl32(pb);
+    uint32_t fields_per_map, map_cnt;
     int i;
+    if (pkt_len < 8)
+        return;
+    fields_per_map = avio_rl32(pb);
+    map_cnt = avio_rl32(pb);
     pkt_len -= 8;
     if ((s->flags & AVFMT_FLAG_IGNIDX) || !s->streams) {
         avio_skip(pb, pkt_len);