Message ID | 20170325080115.55569-1-lq@chinaffmpeg.org |
---|---|
State | Superseded |
Headers | show |
On Sat, Mar 25, 2017 at 9:01 AM, Steven Liu <lq@chinaffmpeg.org> wrote: > refer to SPEC: > Annex E. The FLV File Format said: > E.3 TheFLVFileBody have a table: > Field Type Comment > PreviousTagSize0 UI32 Always 0 > > Signed-off-by: Steven Liu <lq@chinaffmpeg.org> > --- > libavformat/flvdec.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c > index cdcfb9c..ac74b45 100644 > --- a/libavformat/flvdec.c > +++ b/libavformat/flvdec.c > @@ -709,6 +709,7 @@ static int flv_read_header(AVFormatContext *s) > int flags; > FLVContext *flv = s->priv_data; > int offset; > + int pre_tag_size = 0; > > avio_skip(s->pb, 4); > flags = avio_r8(s->pb); > @@ -719,7 +720,17 @@ static int flv_read_header(AVFormatContext *s) > > offset = avio_rb32(s->pb); > avio_seek(s->pb, offset, SEEK_SET); > - avio_skip(s->pb, 4); > + > + /* Annex E. The FLV File Format > + * E.3 TheFLVFileBody > + * Field Type Comment > + * PreviousTagSize0 UI32 Always 0 > + * */ > + pre_tag_size = avio_rb32(s->pb); > + if (pre_tag_size) { > + av_log(s, AV_LOG_ERROR, "Read FLV header error, input file is not a standard flv format, first PreviousTagSize0 always is 0\n"); > + return AVERROR_INVALIDDATA; > + } > What does this exactly break if its not 0? Demuxers should try to be forgiving on non-standard files, so checking some spec limitation like that only makes sense if it has an actual impact on playability of the file. - Hendrik
2017-03-25 16:09 GMT+08:00 Hendrik Leppkes <h.leppkes@gmail.com>: > On Sat, Mar 25, 2017 at 9:01 AM, Steven Liu <lq@chinaffmpeg.org> wrote: > > refer to SPEC: > > Annex E. The FLV File Format said: > > E.3 TheFLVFileBody have a table: > > Field Type Comment > > PreviousTagSize0 UI32 Always 0 > > > > Signed-off-by: Steven Liu <lq@chinaffmpeg.org> > > --- > > libavformat/flvdec.c | 13 ++++++++++++- > > 1 file changed, 12 insertions(+), 1 deletion(-) > > > > diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c > > index cdcfb9c..ac74b45 100644 > > --- a/libavformat/flvdec.c > > +++ b/libavformat/flvdec.c > > @@ -709,6 +709,7 @@ static int flv_read_header(AVFormatContext *s) > > int flags; > > FLVContext *flv = s->priv_data; > > int offset; > > + int pre_tag_size = 0; > > > > avio_skip(s->pb, 4); > > flags = avio_r8(s->pb); > > @@ -719,7 +720,17 @@ static int flv_read_header(AVFormatContext *s) > > > > offset = avio_rb32(s->pb); > > avio_seek(s->pb, offset, SEEK_SET); > > - avio_skip(s->pb, 4); > > + > > + /* Annex E. The FLV File Format > > + * E.3 TheFLVFileBody > > + * Field Type Comment > > + * PreviousTagSize0 UI32 Always 0 > > + * */ > > + pre_tag_size = avio_rb32(s->pb); > > + if (pre_tag_size) { > > + av_log(s, AV_LOG_ERROR, "Read FLV header error, input file is > not a standard flv format, first PreviousTagSize0 always is 0\n"); > > + return AVERROR_INVALIDDATA; > > + } > > > > What does this exactly break if its not 0? > Demuxers should try to be forgiving on non-standard files, so checking > some spec limitation like that only makes sense if it has an actual > impact on playability of the file. > What about give a warning message and do not break? After all the PreviousTagSize0 should always 0. > - Hendrik > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index cdcfb9c..ac74b45 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -709,6 +709,7 @@ static int flv_read_header(AVFormatContext *s) int flags; FLVContext *flv = s->priv_data; int offset; + int pre_tag_size = 0; avio_skip(s->pb, 4); flags = avio_r8(s->pb); @@ -719,7 +720,17 @@ static int flv_read_header(AVFormatContext *s) offset = avio_rb32(s->pb); avio_seek(s->pb, offset, SEEK_SET); - avio_skip(s->pb, 4); + + /* Annex E. The FLV File Format + * E.3 TheFLVFileBody + * Field Type Comment + * PreviousTagSize0 UI32 Always 0 + * */ + pre_tag_size = avio_rb32(s->pb); + if (pre_tag_size) { + av_log(s, AV_LOG_ERROR, "Read FLV header error, input file is not a standard flv format, first PreviousTagSize0 always is 0\n"); + return AVERROR_INVALIDDATA; + } s->start_time = 0; flv->sum_flv_tag_size = 0;
refer to SPEC: Annex E. The FLV File Format said: E.3 TheFLVFileBody have a table: Field Type Comment PreviousTagSize0 UI32 Always 0 Signed-off-by: Steven Liu <lq@chinaffmpeg.org> --- libavformat/flvdec.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)