Message ID | 20200328001733.695-3-lance.lmwang@gmail.com |
---|---|
State | Superseded |
Headers | show |
Series | [FFmpeg-devel,v2,1/3] avfilter/af_acrossover: Check sscanf() return value | expand |
Context | Check | Description |
---|---|---|
andriy/ffmpeg-patchwork | success | Make fate finished |
On Sat, Mar 28, 2020 at 08:17:33AM +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 | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/libavfilter/af_adelay.c b/libavfilter/af_adelay.c > index c964777..2bb05e7 100644 > --- a/libavfilter/af_adelay.c > +++ b/libavfilter/af_adelay.c > @@ -155,7 +155,10 @@ 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) { > + av_log(ctx, AV_LOG_ERROR, "Invalid syntax.\n"); I suggest to print the part of the string that is invalid. This would make it easier to the user to know where the error is thx [...]
On Sat, Mar 28, 2020 at 07:06:13PM +0100, Michael Niedermayer wrote: > On Sat, Mar 28, 2020 at 08:17:33AM +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 | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/libavfilter/af_adelay.c b/libavfilter/af_adelay.c > > index c964777..2bb05e7 100644 > > --- a/libavfilter/af_adelay.c > > +++ b/libavfilter/af_adelay.c > > @@ -155,7 +155,10 @@ 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) { > > > + av_log(ctx, AV_LOG_ERROR, "Invalid syntax.\n"); > > I suggest to print the part of the string that is invalid. > This would make it easier to the user to know where the error is Fixed and update, thx. > > thx > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > No human being will ever know the Truth, for even if they happen to say it > by chance, they would not even known they had done so. -- Xenophanes > _______________________________________________ > 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 --git a/libavfilter/af_adelay.c b/libavfilter/af_adelay.c index c964777..2bb05e7 100644 --- a/libavfilter/af_adelay.c +++ b/libavfilter/af_adelay.c @@ -155,7 +155,10 @@ 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) { + av_log(ctx, AV_LOG_ERROR, "Invalid syntax.\n"); + return AVERROR(EINVAL); + } d->delay = delay * inlink->sample_rate / div; }