Commit c4de49ed authored by Michael Niedermayer's avatar Michael Niedermayer

avformat/electronicarts: If no packet has been read at the end do not treat it...

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/ffmpegReviewed-by: 's avatarPeter Ross <pross@xvid.org>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 87b7e141
...@@ -574,11 +574,12 @@ static int ea_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -574,11 +574,12 @@ static int ea_read_packet(AVFormatContext *s, AVPacket *pkt)
EaDemuxContext *ea = s->priv_data; EaDemuxContext *ea = s->priv_data;
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
int partial_packet = 0; int partial_packet = 0;
int hit_end = 0;
unsigned int chunk_type, chunk_size; unsigned int chunk_type, chunk_size;
int ret = 0, packet_read = 0, key = 0; int ret = 0, packet_read = 0, key = 0;
int av_uninit(num_samples); int av_uninit(num_samples);
while (!packet_read || partial_packet) { while ((!packet_read && !hit_end) || partial_packet) {
chunk_type = avio_rl32(pb); chunk_type = avio_rl32(pb);
chunk_size = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb); chunk_size = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb);
if (chunk_size < 8) if (chunk_size < 8)
...@@ -676,7 +677,7 @@ static int ea_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -676,7 +677,7 @@ static int ea_read_packet(AVFormatContext *s, AVPacket *pkt)
} }
if (avio_feof(pb)) if (avio_feof(pb))
ret = AVERROR_EOF; ret = AVERROR_EOF;
packet_read = 1; hit_end = 1;
break; break;
case MVIh_TAG: case MVIh_TAG:
...@@ -737,6 +738,9 @@ get_video_packet: ...@@ -737,6 +738,9 @@ get_video_packet:
if (ret < 0 && partial_packet) if (ret < 0 && partial_packet)
av_packet_unref(pkt); av_packet_unref(pkt);
if (ret >= 0 && hit_end && !packet_read)
return AVERROR(EAGAIN);
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment