diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2019-09-30 23:42:41 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2019-11-11 20:18:47 +0100 |
commit | 07e77be69f0f3b7b61556438fb149f2b58b5c1b2 (patch) | |
tree | 22b2877adbdfc73c0484c1b25a046a7011861dda | |
parent | 22b9eaf4e69fa2ab7275fd8b39288c6aee346317 (diff) | |
download | ffmpeg-07e77be69f0f3b7b61556438fb149f2b58b5c1b2.tar.gz |
avformat/electronicarts: If no packet has been read at the end do not treat it as if theres a packet
Fixes: Assertion failure
Fixes: 17770/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5700606668308480
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 c4de49edc4652e2f17c8747a6dd9b36ff362017a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/electronicarts.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c index bfd3fed3a2..9ea4c5d708 100644 --- a/libavformat/electronicarts.c +++ b/libavformat/electronicarts.c @@ -574,11 +574,12 @@ static int ea_read_packet(AVFormatContext *s, AVPacket *pkt) EaDemuxContext *ea = s->priv_data; AVIOContext *pb = s->pb; int partial_packet = 0; + int hit_end = 0; unsigned int chunk_type, chunk_size; int ret = 0, packet_read = 0, key = 0; int av_uninit(num_samples); - while (!packet_read || partial_packet) { + while ((!packet_read && !hit_end) || partial_packet) { chunk_type = avio_rl32(pb); chunk_size = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb); if (chunk_size < 8) @@ -676,7 +677,7 @@ static int ea_read_packet(AVFormatContext *s, AVPacket *pkt) } if (avio_feof(pb)) ret = AVERROR_EOF; - packet_read = 1; + hit_end = 1; break; case MVIh_TAG: @@ -737,6 +738,9 @@ get_video_packet: if (ret < 0 && partial_packet) av_packet_unref(pkt); + if (ret >= 0 && hit_end && !packet_read) + return AVERROR(EAGAIN); + return ret; } |