Message ID | 143bf909-8ad3-c567-84d2-3e8d8f09443c@googlemail.com |
---|---|
State | Accepted |
Commit | 872fcfcc0f01230ef761e286b0c6a18817e0a162 |
Headers | show |
On Sun, Oct 23, 2016 at 06:27:02PM +0200, Andreas Cadhalpun wrote: > A negative sample rate doesn't make sense and triggers assertions in > av_rescale_rnd. > > Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> > --- > libavformat/bfi.c | 4 ++++ > 1 file changed, 4 insertions(+) LGTM thx [...]
On Sun, 23 Oct 2016 18:27:02 +0200 Andreas Cadhalpun <andreas.cadhalpun@googlemail.com> wrote: > A negative sample rate doesn't make sense and triggers assertions in > av_rescale_rnd. > > Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> > --- > libavformat/bfi.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/libavformat/bfi.c b/libavformat/bfi.c > index 568363d..ef4c17d 100644 > --- a/libavformat/bfi.c > +++ b/libavformat/bfi.c > @@ -88,6 +88,10 @@ static int bfi_read_header(AVFormatContext * s) > vstream->codecpar->extradata_size); > > astream->codecpar->sample_rate = avio_rl32(pb); > + if (astream->codecpar->sample_rate <= 0) { > + av_log(s, AV_LOG_ERROR, "Invalid sample rate %d\n", astream->codecpar->sample_rate); > + return AVERROR_INVALIDDATA; > + } > > /* Set up the video codec... */ > avpriv_set_pts_info(vstream, 32, 1, fps); Would it make sense to validate codecpars in the generic code (utils.c)?
On 24.10.2016 09:55, wm4 wrote: > On Sun, 23 Oct 2016 18:27:02 +0200 > Andreas Cadhalpun <andreas.cadhalpun@googlemail.com> wrote: > >> A negative sample rate doesn't make sense and triggers assertions in >> av_rescale_rnd. >> >> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> >> --- >> libavformat/bfi.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/libavformat/bfi.c b/libavformat/bfi.c >> index 568363d..ef4c17d 100644 >> --- a/libavformat/bfi.c >> +++ b/libavformat/bfi.c >> @@ -88,6 +88,10 @@ static int bfi_read_header(AVFormatContext * s) >> vstream->codecpar->extradata_size); >> >> astream->codecpar->sample_rate = avio_rl32(pb); >> + if (astream->codecpar->sample_rate <= 0) { >> + av_log(s, AV_LOG_ERROR, "Invalid sample rate %d\n", astream->codecpar->sample_rate); >> + return AVERROR_INVALIDDATA; >> + } >> >> /* Set up the video codec... */ >> avpriv_set_pts_info(vstream, 32, 1, fps); > > Would it make sense to validate codecpars in the generic code (utils.c)? I think that's a good idea. Still, checking the value where it is actually set is good in any case. Best regards, Andreas
diff --git a/libavformat/bfi.c b/libavformat/bfi.c index 568363d..ef4c17d 100644 --- a/libavformat/bfi.c +++ b/libavformat/bfi.c @@ -88,6 +88,10 @@ static int bfi_read_header(AVFormatContext * s) vstream->codecpar->extradata_size); astream->codecpar->sample_rate = avio_rl32(pb); + if (astream->codecpar->sample_rate <= 0) { + av_log(s, AV_LOG_ERROR, "Invalid sample rate %d\n", astream->codecpar->sample_rate); + return AVERROR_INVALIDDATA; + } /* Set up the video codec... */ avpriv_set_pts_info(vstream, 32, 1, fps);
A negative sample rate doesn't make sense and triggers assertions in av_rescale_rnd. Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> --- libavformat/bfi.c | 4 ++++ 1 file changed, 4 insertions(+)