diff mbox series

[FFmpeg-devel,v1,3/3] avfilter/af_adelay: Check sscanf() return value

Message ID 20200325230424.2787-3-lance.lmwang@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel,v1,1/3] avfilter/af_acrossover: Check sscanf() return value | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Lance Wang March 25, 2020, 11:04 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavfilter/af_adelay.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer March 27, 2020, 7:34 p.m. UTC | #1
On Thu, Mar 26, 2020 at 07:04:24AM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavfilter/af_adelay.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/af_adelay.c b/libavfilter/af_adelay.c
> index c9647771f2..7f498ba190 100644
> --- a/libavfilter/af_adelay.c
> +++ b/libavfilter/af_adelay.c
> @@ -155,7 +155,8 @@ static int config_input(AVFilterLink *inlink)
>          ret = av_sscanf(arg, "%d%c", &d->delay, &type);
>          if (ret != 2 || type != 'S') {
>              div = type == 's' ? 1.0 : 1000.0;
> -            av_sscanf(arg, "%f", &delay);
> +            if (av_sscanf(arg, "%f", &delay) != 1)
> +                return AVERROR(EINVAL);

If this case occurs is it clear to the user what is the problem ?
Maybe an error message should be added here

thx

[...]
Lance Wang March 28, 2020, 12:19 a.m. UTC | #2
On Fri, Mar 27, 2020 at 08:34:02PM +0100, Michael Niedermayer wrote:
> On Thu, Mar 26, 2020 at 07:04:24AM +0800, lance.lmwang@gmail.com wrote:
> > From: Limin Wang <lance.lmwang@gmail.com>
> > 
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> >  libavfilter/af_adelay.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavfilter/af_adelay.c b/libavfilter/af_adelay.c
> > index c9647771f2..7f498ba190 100644
> > --- a/libavfilter/af_adelay.c
> > +++ b/libavfilter/af_adelay.c
> > @@ -155,7 +155,8 @@ static int config_input(AVFilterLink *inlink)
> >          ret = av_sscanf(arg, "%d%c", &d->delay, &type);
> >          if (ret != 2 || type != 'S') {
> >              div = type == 's' ? 1.0 : 1000.0;
> > -            av_sscanf(arg, "%f", &delay);
> > +            if (av_sscanf(arg, "%f", &delay) != 1)
> > +                return AVERROR(EINVAL);
> 
> If this case occurs is it clear to the user what is the problem ?
> Maybe an error message should be added here

Yes, I have add error message and update the patch, please review it.

> 
> thx
> 
> [...]
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Let us carefully observe those good qualities wherein our enemies excel us
> and endeavor to excel them, by avoiding what is faulty, and imitating what
> is excellent in them. -- Plutarch



> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavfilter/af_adelay.c b/libavfilter/af_adelay.c
index c9647771f2..7f498ba190 100644
--- a/libavfilter/af_adelay.c
+++ b/libavfilter/af_adelay.c
@@ -155,7 +155,8 @@  static int config_input(AVFilterLink *inlink)
         ret = av_sscanf(arg, "%d%c", &d->delay, &type);
         if (ret != 2 || type != 'S') {
             div = type == 's' ? 1.0 : 1000.0;
-            av_sscanf(arg, "%f", &delay);
+            if (av_sscanf(arg, "%f", &delay) != 1)
+                return AVERROR(EINVAL);
             d->delay = delay * inlink->sample_rate / div;
         }