[FFmpeg-devel] [PATCH] mpegts: prevent division by zero

Michael Niedermayer michael at niedermayer.cc
Tue Nov 8 23:12:12 EET 2016


On Tue, Nov 08, 2016 at 09:38:49PM +0100, Andreas Cadhalpun wrote:
> On 08.11.2016 21:09, Michael Niedermayer wrote:
> > On Tue, Nov 08, 2016 at 07:47:02PM +0100, Andreas Cadhalpun wrote:
> >> On 08.11.2016 00:54, Michael Niedermayer wrote:
> >>> On Mon, Nov 07, 2016 at 11:49:52PM +0100, Andreas Cadhalpun wrote:
> >>>> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> >>>> ---
> >>>>  libavformat/mpegts.c | 4 ++++
> >>>>  1 file changed, 4 insertions(+)
> >>>>
> >>>> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> >>>> index fad10c6..77d63f2 100644
> >>>> --- a/libavformat/mpegts.c
> >>>> +++ b/libavformat/mpegts.c
> >>>> @@ -2692,6 +2692,10 @@ static int mpegts_read_header(AVFormatContext *s)
> >>>>          /* NOTE1: the bitrate is computed without the FEC */
> >>>>          /* NOTE2: it is only the bitrate of the start of the stream */
> >>>>          ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - packet_count[0]);
> >>>> +        if (ts->pcr_incr <= 0) {
> >>>> +            av_log(s, AV_LOG_ERROR, "invalid pcr increment %d\n", ts->pcr_incr);
> >>>> +            return AVERROR_INVALIDDATA;
> >>>> +        }
> >>>
> >>> if a pcr pair is bad i would suggest to run the loop by another
> >>> iteration
> >>
> >> That's a good idea. New patch attached.
> > 
> > LGTM, maybe add a av_log() so the user knows of the issue
> 
> Makes sense, patch with added log message is attached.
> 
> > (especially
> > if all pcr are systematically bad, n which case this would need to be
> > adjusted to not fail)
> 
> What do you think should be done in that case?

if you want to implement that case before theres a file found that
needs it,
ignore the pcr, set things that depend on them to "unknown" /
AV_NOPTS_VALUE

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20161108/9e9a0ac9/attachment.sig>


More information about the ffmpeg-devel mailing list