From: Alexander Alekhin Date: Thu, 25 Feb 2021 20:16:50 +0000 (+0000) Subject: imgproc(warpAffine): avoid buffer indexes overflow in SIMD code X-Git-Tag: submit/tizen/20220120.021815~1^2~1^2~140^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fadb25baf86fa23c75bfef807ed498bb179040c4;p=platform%2Fupstream%2Fopencv.git imgproc(warpAffine): avoid buffer indexes overflow in SIMD code --- diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index 1665e0a40c..298f9b3b5b 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -446,7 +446,7 @@ struct RemapVec_8u { int cn = _src.channels(), x = 0, sstep = (int)_src.step; - if( (cn != 1 && cn != 3 && cn != 4) || sstep > 0x8000 ) + if( (cn != 1 && cn != 3 && cn != 4) || sstep >= 0x8000 ) return 0; const uchar *S0 = _src.ptr(), *S1 = _src.ptr(1); diff --git a/modules/imgproc/test/test_imgwarp.cpp b/modules/imgproc/test/test_imgwarp.cpp index 73d513e85f..7d0360dfb1 100644 --- a/modules/imgproc/test/test_imgwarp.cpp +++ b/modules/imgproc/test/test_imgwarp.cpp @@ -1781,6 +1781,26 @@ TEST(Imgproc_Warp, multichannel) } } + +TEST(Imgproc_Warp, regression_19566) // valgrind should detect problem if any +{ + const Size imgSize(8192, 8); + + Mat inMat = Mat::zeros(imgSize, CV_8UC4); + Mat outMat = Mat::zeros(imgSize, CV_8UC4); + + warpAffine( + inMat, + outMat, + getRotationMatrix2D(Point2f(imgSize.width / 2.0f, imgSize.height / 2.0f), 45.0, 1.0), + imgSize, + INTER_LINEAR, + cv::BORDER_CONSTANT, + cv::Scalar(0.0, 0.0, 0.0, 255.0) + ); +} + + TEST(Imgproc_GetAffineTransform, singularity) { Point2f A_sample[3];