[FFmpeg-cvslog] swscale/swscale: Add some sanity checks for srcSlice* parameters

Michael Niedermayer git at videolan.org
Mon Feb 1 02:35:22 CET 2016


ffmpeg | branch: release/2.4 | Michael Niedermayer <michael at niedermayer.cc> | Sun Jan 17 18:57:01 2016 +0100| [5d40272ba8fcae15d39422c8ceeae6112735300f] | committer: Michael Niedermayer

swscale/swscale: Add some sanity checks for srcSlice* parameters

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 321e85e1769ca1fc1567025ae264760790ee7fc9)

Conflicts:

	libswscale/swscale.c

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5d40272ba8fcae15d39422c8ceeae6112735300f
---

 libswscale/swscale.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 43b8740..87fd63a 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -895,11 +895,19 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
     const uint8_t *src2[4];
     uint8_t *dst2[4];
     uint8_t *rgb0_tmp = NULL;
+    int macro_height = isBayer(c->srcFormat) ? 2 : (1 << c->chrSrcVSubSample);
 
     if (!srcStride || !dstStride || !dst || !srcSlice) {
         av_log(c, AV_LOG_ERROR, "One of the input parameters to sws_scale() is NULL, please check the calling code\n");
         return 0;
     }
+
+    if ((srcSliceY & (macro_height-1)) ||
+        ((srcSliceH& (macro_height-1)) && srcSliceY + srcSliceH != c->srcH) ||
+        srcSliceY + srcSliceH > c->srcH) {
+        av_log(c, AV_LOG_ERROR, "Slice parameters %d, %d are invalid\n", srcSliceY, srcSliceH);
+        return AVERROR(EINVAL);
+    }
     if (c->cascaded_context[0] && srcSliceY == 0 && srcSliceH == c->cascaded_context[0]->srcH) {
         ret = sws_scale(c->cascaded_context[0],
                         srcSlice, srcStride, srcSliceY, srcSliceH,



More information about the ffmpeg-cvslog mailing list