Message ID | 20200103155636.7476-8-nicolas.gaullier@cji.paris |
---|---|
State | New |
Headers | show |
Series | avformat: Use s337m subdemux inside wav | expand |
Context | Check | Description |
---|---|---|
andriy/ffmpeg-patchwork | success | Make fate finished |
fre 2020-01-03 klockan 16:56 +0100 skrev Nicolas Gaullier: > Fix reading beyond data_end. > --- > libavformat/wavdec.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c > index ccb9576b84..039ec1658e 100644 > --- a/libavformat/wavdec.c > +++ b/libavformat/wavdec.c > @@ -643,8 +643,6 @@ static int wav_read_packet(AVFormatContext *s, AVPacket *pkt) > > if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1) > return ff_spdif_read_packet(s, pkt); > - if (CONFIG_S337M_DEMUXER && wav->s337m == 1) > - return ff_s337m_read_packet(s, pkt); > > if (wav->smv_data_ofs > 0) { > int64_t audio_dts, video_dts; > @@ -712,6 +710,10 @@ smv_out: > wav->data_end = avio_tell(s->pb) + left; > } > > + if (CONFIG_S337M_DEMUXER && wav->s337m == 1) { > + size = FFMIN(S337M_MAX_OFFSET, left); > + ret = ff_s337m_get_packet(s->pb, pkt, size, NULL, s, st->codecpar->bits_per_coded_sample); > + } else { Couldn't you roll this into the patch that adds the call to ff_s337m_read_packet()? /Tomas
>> if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1) >> return ff_spdif_read_packet(s, pkt); >> - if (CONFIG_S337M_DEMUXER && wav->s337m == 1) >> - return ff_s337m_read_packet(s, pkt); >> >> if (wav->smv_data_ofs > 0) { >> int64_t audio_dts, video_dts; @@ -712,6 +710,10 @@ smv_out: >> wav->data_end = avio_tell(s->pb) + left; >> } >> >> + if (CONFIG_S337M_DEMUXER && wav->s337m == 1) { >> + size = FFMIN(S337M_MAX_OFFSET, left); >> + ret = ff_s337m_get_packet(s->pb, pkt, size, NULL, s, st->codecpar->bits_per_coded_sample); >> + } else { > >Couldn't you roll this into the patch that adds the call to ff_s337m_read_packet()? OK. I was not sure about it. I thought it might have been interesting to keep s337m as close as possible to spdif as long as possible, and then only fork at the very end with this last patch, but maybe it is does not make so much sense. Thus, I will move ff_s337m_read_packet() back to a static s337m_read_packet(), I think this is better as indeed s337m_read_packet should never be used from outside when s337m is submuxed in another mux because it does not restrict the available size that could be read from avio. Nicolas
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index ccb9576b84..039ec1658e 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -643,8 +643,6 @@ static int wav_read_packet(AVFormatContext *s, AVPacket *pkt) if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1) return ff_spdif_read_packet(s, pkt); - if (CONFIG_S337M_DEMUXER && wav->s337m == 1) - return ff_s337m_read_packet(s, pkt); if (wav->smv_data_ofs > 0) { int64_t audio_dts, video_dts; @@ -712,6 +710,10 @@ smv_out: wav->data_end = avio_tell(s->pb) + left; } + if (CONFIG_S337M_DEMUXER && wav->s337m == 1) { + size = FFMIN(S337M_MAX_OFFSET, left); + ret = ff_s337m_get_packet(s->pb, pkt, size, NULL, s, st->codecpar->bits_per_coded_sample); + } else { size = MAX_SIZE; if (st->codecpar->block_align > 1) { if (size < st->codecpar->block_align) @@ -720,6 +722,8 @@ smv_out: } size = FFMIN(size, left); ret = av_get_packet(s->pb, pkt, size); + } + if (ret < 0) return ret; pkt->stream_index = 0;