]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/vf_minterpolate: Reject too small dimensions
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 6 Oct 2020 12:35:25 +0000 (14:35 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 9 Oct 2020 14:38:28 +0000 (16:38 +0200)
The latter code relies upon the dimensions to be not too small;
otherwise one will call av_clip() with min > max lateron which aborts
in case ASSERT_LEVEL is >= 2 or one will get a nonsense result that may
lead to a heap-buffer-overflow/underflow. The latter has happened in
ticket #8248 which this commit fixes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavfilter/vf_minterpolate.c

index c9ce80420d519f039d70e140c4c3afdde3edef4e..e1fe5e32b587d91fca4717074fa2434c14c4277e 100644 (file)
@@ -363,6 +363,11 @@ static int config_input(AVFilterLink *inlink)
     }
 
     if (mi_ctx->mi_mode == MI_MODE_MCI) {
+        if (mi_ctx->b_width < 2 || mi_ctx->b_height < 2) {
+            av_log(inlink->dst, AV_LOG_ERROR, "Height or width < %d\n",
+                   2 * mi_ctx->mb_size);
+            return AVERROR(EINVAL);
+        }
         mi_ctx->pixel_mvs = av_mallocz_array(width * height, sizeof(PixelMVS));
         mi_ctx->pixel_weights = av_mallocz_array(width * height, sizeof(PixelWeights));
         mi_ctx->pixel_refs = av_mallocz_array(width * height, sizeof(PixelRefs));