avfilter/af_silenceremove: fix possible crash if supplied duration is negative
authorPaul B Mahol <onemda@gmail.com>
Mon, 27 Nov 2017 15:32:54 +0000 (16:32 +0100)
committerCarl Eugen Hoyos <ceffmpeg@gmail.com>
Thu, 24 Jan 2019 23:53:39 +0000 (00:53 +0100)
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Fixes ticket #7697.
(cherry picked from commit 2d1594a8d6a754a426cb53184dccf9cf8c8a94b0)

libavfilter/af_silenceremove.c

index f156d18..3d3651a 100644 (file)
@@ -186,8 +186,17 @@ static int config_input(AVFilterLink *inlink)
 
     s->start_duration = av_rescale(s->start_duration, inlink->sample_rate,
                                    AV_TIME_BASE);
+    if (s->start_duration < 0) {
+        av_log(ctx, AV_LOG_WARNING, "start duration must be non-negative\n");
+        s->start_duration = -s->start_duration;
+    }
+
     s->stop_duration  = av_rescale(s->stop_duration, inlink->sample_rate,
                                    AV_TIME_BASE);
+    if (s->stop_duration < 0) {
+        av_log(ctx, AV_LOG_WARNING, "stop duration must be non-negative\n");
+        s->stop_duration = -s->stop_duration;
+    }
 
     s->start_holdoff = av_malloc_array(FFMAX(s->start_duration, 1),
                                        sizeof(*s->start_holdoff) *