Browse Source

avformat/icodec: Check for zero streams and stream creation failure

Fixes: NULL pointer dereference
Fixes: 26814/clusterfuzz-testcase-minimized-ffmpeg_dem_ICO_fuzzer-5758487797432320

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b33233bd53)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
tags/n4.3.2
Michael Niedermayer 5 years ago
parent
commit
aed96e94c7
1 changed files with 5 additions and 2 deletions
  1. +5
    -2
      libavformat/icodec.c

+ 5
- 2
libavformat/icodec.c View File

@@ -84,6 +84,9 @@ static int read_header(AVFormatContext *s)
avio_skip(pb, 4);
ico->nb_images = avio_rl16(pb);

if (!ico->nb_images)
return AVERROR_INVALIDDATA;

ico->images = av_malloc_array(ico->nb_images, sizeof(IcoImage));
if (!ico->images)
return AVERROR(ENOMEM);
@@ -93,7 +96,7 @@ static int read_header(AVFormatContext *s)
int tmp;

if (avio_seek(pb, 6 + i * 16, SEEK_SET) < 0)
break;
goto fail;

st = avformat_new_stream(s, NULL);
if (!st) {
@@ -118,7 +121,7 @@ static int read_header(AVFormatContext *s)
ico->images[i].offset = avio_rl32(pb);

if (avio_seek(pb, ico->images[i].offset, SEEK_SET) < 0)
break;
goto fail;

codec = avio_rl32(pb);
switch (codec) {


Loading…
Cancel
Save