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

Stefano Sabatini stefasab at gmail.com
Tue Apr 16 00:28:01 CEST 2013


On date Tuesday 2013-04-16 00:05:45 +0200, Michael Niedermayer encoded:
> 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

I see. Well at least you could push the checks which don't seem too
ugly.
-- 
FFmpeg = Free and Fundamentalist Majestic Picky Evangelical Geisha


More information about the ffmpeg-devel mailing list