diff mbox series

[FFmpeg-devel,06/11] avutil/eval: Unconditionally check argument of e_div

Message ID 20201020205619.7939-6-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,01/11] avcodec/notchlc: Check uncompressed size against input for LZ4
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Michael Niedermayer Oct. 20, 2020, 8:56 p.m. UTC
Fixes: division by zero
Fixes: 26451/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVO_fuzzer-4756955832516608

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavutil/eval.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andreas Rheinhardt Oct. 21, 2020, 5:20 a.m. UTC | #1
Michael Niedermayer:
> Fixes: division by zero
> Fixes: 26451/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVO_fuzzer-4756955832516608
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavutil/eval.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavutil/eval.c b/libavutil/eval.c
> index d527f6a9d0..aaa8eb4945 100644
> --- a/libavutil/eval.c
> +++ b/libavutil/eval.c
> @@ -317,7 +317,7 @@ static double eval_expr(Parser *p, AVExpr *e)
>                  case e_lte: return e->value * (d <= d2 ? 1.0 : 0.0);
>                  case e_pow: return e->value * pow(d, d2);
>                  case e_mul: return e->value * (d * d2);
> -                case e_div: return e->value * ((!CONFIG_FTRAPV || d2 ) ? (d / d2) : d * INFINITY);
> +                case e_div: return e->value * (d2 ? (d / d2) : d * INFINITY);
>                  case e_add: return e->value * (d + d2);
>                  case e_last:return e->value * d2;
>                  case e_st : return e->value * (p->var[av_clip(d, 0, VARS-1)]= d2);
> 
What division by zero (does the fuzzer complain about floating point
division by zero?)?

- Andreas
Michael Niedermayer Oct. 21, 2020, 10:52 a.m. UTC | #2
On Wed, Oct 21, 2020 at 07:20:41AM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: division by zero
> > Fixes: 26451/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVO_fuzzer-4756955832516608
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavutil/eval.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavutil/eval.c b/libavutil/eval.c
> > index d527f6a9d0..aaa8eb4945 100644
> > --- a/libavutil/eval.c
> > +++ b/libavutil/eval.c
> > @@ -317,7 +317,7 @@ static double eval_expr(Parser *p, AVExpr *e)
> >                  case e_lte: return e->value * (d <= d2 ? 1.0 : 0.0);
> >                  case e_pow: return e->value * pow(d, d2);
> >                  case e_mul: return e->value * (d * d2);
> > -                case e_div: return e->value * ((!CONFIG_FTRAPV || d2 ) ? (d / d2) : d * INFINITY);
> > +                case e_div: return e->value * (d2 ? (d / d2) : d * INFINITY);
> >                  case e_add: return e->value * (d + d2);
> >                  case e_last:return e->value * d2;
> >                  case e_st : return e->value * (p->var[av_clip(d, 0, VARS-1)]= d2);
> > 
> What division by zero (does the fuzzer complain about floating point
> division by zero?)?

I see nothing else, so i guess yes.
we can drop this patch, or apply it to silence this, whatever is preferred

thx

[...]
diff mbox series

Patch

diff --git a/libavutil/eval.c b/libavutil/eval.c
index d527f6a9d0..aaa8eb4945 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -317,7 +317,7 @@  static double eval_expr(Parser *p, AVExpr *e)
                 case e_lte: return e->value * (d <= d2 ? 1.0 : 0.0);
                 case e_pow: return e->value * pow(d, d2);
                 case e_mul: return e->value * (d * d2);
-                case e_div: return e->value * ((!CONFIG_FTRAPV || d2 ) ? (d / d2) : d * INFINITY);
+                case e_div: return e->value * (d2 ? (d / d2) : d * INFINITY);
                 case e_add: return e->value * (d + d2);
                 case e_last:return e->value * d2;
                 case e_st : return e->value * (p->var[av_clip(d, 0, VARS-1)]= d2);