[FFmpeg-devel] [PATCH 4/4] avutil/opt: add some checks for type vs. range

Michael Niedermayer michaelni at gmx.at
Tue Apr 16 00:05:45 CEST 2013


On Mon, Apr 15, 2013 at 09:58:37PM +0200, Stefano Sabatini wrote:
> On date Saturday 2013-04-13 20:37:15 +0200, Michael Niedermayer encoded:
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> >  libavutil/opt.c |    3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/libavutil/opt.c b/libavutil/opt.c
> > index 60d943c..1c4e40d 100644
> > --- a/libavutil/opt.c
> > +++ b/libavutil/opt.c
> > @@ -72,8 +72,11 @@ const AVOption *av_opt_next(void *obj, const AVOption *last)
> >              faulty |= (o->min > o->default_val.dbl || o->default_val.dbl > o->max);
> >          } else if (o->type == AV_OPT_TYPE_INT || o->type == AV_OPT_TYPE_INT64) {
> >              faulty |= (o->min > o->default_val.i64 || o->default_val.i64 > o->max);
> > +            if (o->type == AV_OPT_TYPE_INT)
> > +                faulty |= (o->min < INT_MIN || o->max > UINT_MAX);
> 
> can o->max be really > INT_MAX?

yes its used for an unsigned int somewhere
i dont remember where but shouldnt be hard to find


> 
> >          } else if (o->type == AV_OPT_TYPE_RATIONAL) {
> >              faulty |= (o->min > av_q2d(o->default_val.q) || av_q2d(o->default_val.q) > o->max);
> 
> > +            faulty |= (o->min < INT_MIN || (o->max > INT_MAX && o->max != DBL_MAX));
> 
> can you explain this?

Rational may be 1/0 aka +infinty
INFINITY itself isnt used because it can be defined in a way that isnt
a constant (would break compile of the table code, see
libavutil/mathematics.h:#define INFINITY       av_int2float(0x7f800000)
so DBL_MAX is used instead

why not for min too ? because it wasnt needed to pass without assert
failure.
Yes again this code is messy which is why iam uncertain its  a good
idea for git master

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

DNS cache poisoning attacks, popular search engine, Google internet authority
dont be evil, please
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130416/14c30fec/attachment.asc>


More information about the ffmpeg-devel mailing list