aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-11-04 01:06:46 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-10-17 21:34:53 +0200
commit452faa80b431afb9ecfba9ef8e85856221d2a5ca (patch)
tree00e65586714671a4dceae1d8d6294aa59ecda398
parentd5c4d054822601e6bb57b12bfe69686d042dc792 (diff)
downloadffmpeg-452faa80b431afb9ecfba9ef8e85856221d2a5ca.tar.gz
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 b33233bd53f74f94f4cd7be0645a99a9549a913e) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/icodec.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavformat/icodec.c b/libavformat/icodec.c
index c07238ec67..9320862b9b 100644
--- a/libavformat/icodec.c
+++ b/libavformat/icodec.c
@@ -58,6 +58,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);
@@ -67,7 +70,7 @@ static int read_header(AVFormatContext *s)
int tmp;
if (avio_seek(pb, 6 + i * 16, SEEK_SET) < 0)
- break;
+ return AVERROR_INVALIDDATA;
st = avformat_new_stream(s, NULL);
if (!st)
@@ -90,7 +93,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;
+ return AVERROR_INVALIDDATA;
codec = avio_rl32(pb);
switch (codec) {