Message ID | 20190930231254.23993-1-michael@niedermayer.cc |
---|---|
State | Accepted |
Commit | c4de49edc4652e2f17c8747a6dd9b36ff362017a |
Headers | show |
On Tue, Oct 01, 2019 at 01:12:50AM +0200, Michael Niedermayer wrote: > 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 > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> > --- > libavformat/electronicarts.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c > index 6dbc3e350a..c894663c29 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; > } looks good. -- Peter loo(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
On Tue, Oct 01, 2019 at 10:23:08PM +1000, Peter Ross wrote: > On Tue, Oct 01, 2019 at 01:12:50AM +0200, Michael Niedermayer wrote: > > 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 > > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> > > --- > > libavformat/electronicarts.c | 8 ++++++-- > > 1 file changed, 6 insertions(+), 2 deletions(-) > > > > diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c > > index 6dbc3e350a..c894663c29 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; > > } > > looks good. will apply thx [...]
diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c index 6dbc3e350a..c894663c29 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; }
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 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavformat/electronicarts.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)