summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jansa <martin.jansa@gmail.com>2021-03-21 09:15:34 +0100
committerArmin Kuster <akuster808@gmail.com>2021-04-07 08:55:15 -0700
commit637967e804ff6ea17727647c25364da6c55d5ef8 (patch)
tree598370d9a7e132def8f8291ebca608b36be256bd
parent7796f4ce08402f6999717faebf29c1722d21d76c (diff)
downloadmeta-openembedded-637967e804ff6ea17727647c25364da6c55d5ef8.tar.gz
opencv: refresh patches with devtool to apply cleanly
* fixes: WARNING: opencv-4.1.0-r0 do_patch: Fuzz detected: Applying patch CVE-2019-14491.patch patching file modules/objdetect/src/cascadedetect.cpp Hunk #1 succeeded at 46 with fuzz 1 (offset -1 lines). Hunk #2 succeeded at 540 (offset -1 lines). Hunk #3 succeeded at 552 (offset -1 lines). Hunk #4 succeeded at 613 (offset -1 lines). Hunk #5 succeeded at 774 (offset -1 lines). Hunk #6 succeeded at 825 (offset -1 lines). Hunk #7 succeeded at 1470 (offset -36 lines). patching file modules/objdetect/src/cascadedetect.hpp The context lines in the patches can be updated with devtool: devtool modify opencv devtool finish --force-patch-refresh opencv <layer_path> Don't forget to review changes done by devtool! WARNING: opencv-4.1.0-r0 do_patch: QA Issue: Patch log indicates that patches do not apply cleanly. [patch-fuzz] Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r--meta-oe/recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch4
-rw-r--r--meta-oe/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch4
-rw-r--r--meta-oe/recipes-support/opencv/opencv/0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch4
-rw-r--r--meta-oe/recipes-support/opencv/opencv/0001-carotene-Replace-ipcp-unit-growth-with-ipa-cp-unit-g.patch9
-rw-r--r--meta-oe/recipes-support/opencv/opencv/0002-Make-opencv-ts-create-share-library-intead-of-static.patch4
-rw-r--r--meta-oe/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch8
-rw-r--r--meta-oe/recipes-support/opencv/opencv/CVE-2019-14491.patch56
-rw-r--r--meta-oe/recipes-support/opencv/opencv/CVE-2019-14493.patch104
-rw-r--r--meta-oe/recipes-support/opencv/opencv/CVE-2019-15939.patch20
-rw-r--r--meta-oe/recipes-support/opencv/opencv/CVE-2019-19624.patch22
-rw-r--r--meta-oe/recipes-support/opencv/opencv/download.patch9
11 files changed, 126 insertions, 118 deletions
diff --git a/meta-oe/recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch b/meta-oe/recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch
index 5f909c1a8f..896d6ce9dc 100644
--- a/meta-oe/recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch
+++ b/meta-oe/recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch
@@ -1,4 +1,4 @@
1From 85b882b4ceb57fe6538f47af58d0a970923fde0e Mon Sep 17 00:00:00 2001 1From 806de12b95a69572fffea8eb49b4ec3fb722b65f Mon Sep 17 00:00:00 2001
2From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> 2From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
3Date: Thu, 31 Mar 2016 00:20:15 +0200 3Date: Thu, 31 Mar 2016 00:20:15 +0200
4Subject: [PATCH] 3rdparty/ippicv: Use pre-downloaded ipp 4Subject: [PATCH] 3rdparty/ippicv: Use pre-downloaded ipp
@@ -11,7 +11,7 @@ Signed-off-by: Ismo Puustinen <ismo.puustinen@intel.com>
11 1 file changed, 1 insertion(+), 14 deletions(-) 11 1 file changed, 1 insertion(+), 14 deletions(-)
12 12
13diff --git a/3rdparty/ippicv/ippicv.cmake b/3rdparty/ippicv/ippicv.cmake 13diff --git a/3rdparty/ippicv/ippicv.cmake b/3rdparty/ippicv/ippicv.cmake
14index ae8748c..305abdb 100644 14index ae8748c283..305abdb58d 100644
15--- a/3rdparty/ippicv/ippicv.cmake 15--- a/3rdparty/ippicv/ippicv.cmake
16+++ b/3rdparty/ippicv/ippicv.cmake 16+++ b/3rdparty/ippicv/ippicv.cmake
17@@ -39,18 +39,5 @@ function(download_ippicv root_var) 17@@ -39,18 +39,5 @@ function(download_ippicv root_var)
diff --git a/meta-oe/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch b/meta-oe/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch
index 40d3f53e1a..a899b7e9a4 100644
--- a/meta-oe/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch
+++ b/meta-oe/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch
@@ -1,4 +1,4 @@
1From 9659f5a1e75fc29c9879c301767bba72ecf9042a Mon Sep 17 00:00:00 2001 1From b34a6e8d4582aa13ad4cd58547d8e0f0a0f1c6a6 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 11 Sep 2018 00:21:18 -0700 3Date: Tue, 11 Sep 2018 00:21:18 -0700
4Subject: [PATCH] Dont use isystem 4Subject: [PATCH] Dont use isystem
@@ -14,7 +14,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
14 1 file changed, 2 insertions(+) 14 1 file changed, 2 insertions(+)
15 15
16diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake 16diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake
17index 59bc826..055dfce 100644 17index 59bc826ed0..055dfce251 100644
18--- a/cmake/OpenCVPCHSupport.cmake 18--- a/cmake/OpenCVPCHSupport.cmake
19+++ b/cmake/OpenCVPCHSupport.cmake 19+++ b/cmake/OpenCVPCHSupport.cmake
20@@ -18,6 +18,8 @@ IF(CV_GCC) 20@@ -18,6 +18,8 @@ IF(CV_GCC)
diff --git a/meta-oe/recipes-support/opencv/opencv/0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch b/meta-oe/recipes-support/opencv/opencv/0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch
index f8ccd1d558..26041e09fb 100644
--- a/meta-oe/recipes-support/opencv/opencv/0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch
+++ b/meta-oe/recipes-support/opencv/opencv/0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch
@@ -1,4 +1,4 @@
1From fe27d0e2341683606704115949d16250e4cacbfa Mon Sep 17 00:00:00 2001 1From 23425e45f6e26f2b1e387b88e104872b3a1ea5d1 Mon Sep 17 00:00:00 2001
2From: Jason Wessel <jason.wessel@windriver.com> 2From: Jason Wessel <jason.wessel@windriver.com>
3Date: Wed, 9 May 2018 13:33:59 -0700 3Date: Wed, 9 May 2018 13:33:59 -0700
4Subject: [PATCH] Temporarliy work around deprecated ffmpeg RAW function 4Subject: [PATCH] Temporarliy work around deprecated ffmpeg RAW function
@@ -11,7 +11,7 @@ Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
11 1 file changed, 8 insertions(+) 11 1 file changed, 8 insertions(+)
12 12
13diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp 13diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp
14index 0d360ad..566df66 100644 14index 0d360ad5d9..566df6664b 100644
15--- a/modules/videoio/src/cap_ffmpeg_impl.hpp 15--- a/modules/videoio/src/cap_ffmpeg_impl.hpp
16+++ b/modules/videoio/src/cap_ffmpeg_impl.hpp 16+++ b/modules/videoio/src/cap_ffmpeg_impl.hpp
17@@ -736,6 +736,14 @@ struct ImplMutex::Impl 17@@ -736,6 +736,14 @@ struct ImplMutex::Impl
diff --git a/meta-oe/recipes-support/opencv/opencv/0001-carotene-Replace-ipcp-unit-growth-with-ipa-cp-unit-g.patch b/meta-oe/recipes-support/opencv/opencv/0001-carotene-Replace-ipcp-unit-growth-with-ipa-cp-unit-g.patch
index 43d32fbc75..df5bd67460 100644
--- a/meta-oe/recipes-support/opencv/opencv/0001-carotene-Replace-ipcp-unit-growth-with-ipa-cp-unit-g.patch
+++ b/meta-oe/recipes-support/opencv/opencv/0001-carotene-Replace-ipcp-unit-growth-with-ipa-cp-unit-g.patch
@@ -1,13 +1,15 @@
1From 1edc925ecd7fb54d2dc78452069084475fbe2a70 Mon Sep 17 00:00:00 2001 1From d9bdafa95f329f33d829d89a2e51adaf833768cc Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 16 Jan 2020 08:52:00 -0800 3Date: Thu, 16 Jan 2020 08:52:00 -0800
4Subject: [PATCH] carotene: Replace ipcp-unit-growth with ipa-cp-unit-growth on gcc >= 10 4Subject: [PATCH] carotene: Replace ipcp-unit-growth with ipa-cp-unit-growth on
5 gcc >= 10
5 6
6gcc 10+ has renamed this option, therefore check for gcc version before 7gcc 10+ has renamed this option, therefore check for gcc version before
7deciding which name to use for opt parameter 8deciding which name to use for opt parameter
8 9
9Upstream-Status: Submitted [https://github.com/opencv/opencv/pull/16369] 10Upstream-Status: Submitted [https://github.com/opencv/opencv/pull/16369]
10Signed-off-by: Khem Raj <raj.khem@gmail.com> 11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12
11--- 13---
12 3rdparty/carotene/CMakeLists.txt | 8 ++++++-- 14 3rdparty/carotene/CMakeLists.txt | 8 ++++++--
13 3rdparty/carotene/hal/CMakeLists.txt | 7 ++++++- 15 3rdparty/carotene/hal/CMakeLists.txt | 7 ++++++-
@@ -50,6 +52,3 @@ index c4b9acaedd..bbc5b11a80 100644
50 # set_source_files_properties(impl.cpp $<TARGET_OBJECTS:carotene_objs> COMPILE_FLAGS "--param ipcp-unit-growth=100000 --param inline-unit-growth=100000 --param large-stack-frame-growth=5000") 52 # set_source_files_properties(impl.cpp $<TARGET_OBJECTS:carotene_objs> COMPILE_FLAGS "--param ipcp-unit-growth=100000 --param inline-unit-growth=100000 --param large-stack-frame-growth=5000")
51 endif() 53 endif()
52 54
53--
542.25.0
55
diff --git a/meta-oe/recipes-support/opencv/opencv/0002-Make-opencv-ts-create-share-library-intead-of-static.patch b/meta-oe/recipes-support/opencv/opencv/0002-Make-opencv-ts-create-share-library-intead-of-static.patch
index 46198fb7be..3dd63829e5 100644
--- a/meta-oe/recipes-support/opencv/opencv/0002-Make-opencv-ts-create-share-library-intead-of-static.patch
+++ b/meta-oe/recipes-support/opencv/opencv/0002-Make-opencv-ts-create-share-library-intead-of-static.patch
@@ -1,4 +1,4 @@
1From 46ffa1f8f443b71673774fcb864eb741bbc26200 Mon Sep 17 00:00:00 2001 1From 6a490df70aadc43ed4f503452c278e334716826d Mon Sep 17 00:00:00 2001
2From: Bian Naimeng <biannm@cn.fujitsu.com> 2From: Bian Naimeng <biannm@cn.fujitsu.com>
3Date: Wed, 19 Apr 2017 03:11:37 +0900 3Date: Wed, 19 Apr 2017 03:11:37 +0900
4Subject: [PATCH] Make opencv-ts create share library intead of static. 4Subject: [PATCH] Make opencv-ts create share library intead of static.
@@ -10,7 +10,7 @@ Signed-off-by: Lei Maohui <leimaohui@cn.fujitsu.com>
10 1 file changed, 1 insertion(+), 1 deletion(-) 10 1 file changed, 1 insertion(+), 1 deletion(-)
11 11
12diff --git a/modules/ts/CMakeLists.txt b/modules/ts/CMakeLists.txt 12diff --git a/modules/ts/CMakeLists.txt b/modules/ts/CMakeLists.txt
13index f95bed0..ee67858 100644 13index f95bed0793..ee67858df8 100644
14--- a/modules/ts/CMakeLists.txt 14--- a/modules/ts/CMakeLists.txt
15+++ b/modules/ts/CMakeLists.txt 15+++ b/modules/ts/CMakeLists.txt
16@@ -4,7 +4,7 @@ if(NOT BUILD_opencv_ts AND NOT BUILD_TESTS AND NOT BUILD_PERF_TESTS) 16@@ -4,7 +4,7 @@ if(NOT BUILD_opencv_ts AND NOT BUILD_TESTS AND NOT BUILD_PERF_TESTS)
diff --git a/meta-oe/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch b/meta-oe/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch
index 336c2e08e6..77571ead98 100644
--- a/meta-oe/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch
+++ b/meta-oe/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch
@@ -1,4 +1,4 @@
1From 867caccc358266f7021f076fc8c8e41bf048782c Mon Sep 17 00:00:00 2001 1From b3dc5478cb0d2d2b617dc6c5e28d59559edadf36 Mon Sep 17 00:00:00 2001
2From: Huang Qiyu <huangqy.fnst@cn.fujitsu.com> 2From: Huang Qiyu <huangqy.fnst@cn.fujitsu.com>
3Date: Fri, 19 May 2017 04:27:50 +0900 3Date: Fri, 19 May 2017 04:27:50 +0900
4Subject: [PATCH] To fix errors as following: 4Subject: [PATCH] To fix errors as following:
@@ -21,7 +21,7 @@ Signed-off-by: Ismo Puustinen <ismo.puustinen@intel.com>
21 3 files changed, 4 insertions(+), 4 deletions(-) 21 3 files changed, 4 insertions(+), 4 deletions(-)
22 22
23diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp 23diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp
24index b9d6b74..f1ee7ee 100644 24index b9d6b74ffc..f1ee7ee429 100644
25--- a/modules/ts/include/opencv2/ts.hpp 25--- a/modules/ts/include/opencv2/ts.hpp
26+++ b/modules/ts/include/opencv2/ts.hpp 26+++ b/modules/ts/include/opencv2/ts.hpp
27@@ -622,7 +622,7 @@ protected: 27@@ -622,7 +622,7 @@ protected:
@@ -43,7 +43,7 @@ index b9d6b74..f1ee7ee 100644
43 #define CV_TEST_INIT0_NOOP (void)0 43 #define CV_TEST_INIT0_NOOP (void)0
44 44
45diff --git a/modules/ts/include/opencv2/ts/ocl_test.hpp b/modules/ts/include/opencv2/ts/ocl_test.hpp 45diff --git a/modules/ts/include/opencv2/ts/ocl_test.hpp b/modules/ts/include/opencv2/ts/ocl_test.hpp
46index 11572e9..438112e 100644 46index 11572e9f48..438112e2aa 100644
47--- a/modules/ts/include/opencv2/ts/ocl_test.hpp 47--- a/modules/ts/include/opencv2/ts/ocl_test.hpp
48+++ b/modules/ts/include/opencv2/ts/ocl_test.hpp 48+++ b/modules/ts/include/opencv2/ts/ocl_test.hpp
49@@ -82,7 +82,7 @@ inline UMat ToUMat(InputArray src) 49@@ -82,7 +82,7 @@ inline UMat ToUMat(InputArray src)
@@ -56,7 +56,7 @@ index 11572e9..438112e 100644
56 #define MAX_VALUE 357 56 #define MAX_VALUE 357
57 57
58diff --git a/modules/ts/include/opencv2/ts/ts_ext.hpp b/modules/ts/include/opencv2/ts/ts_ext.hpp 58diff --git a/modules/ts/include/opencv2/ts/ts_ext.hpp b/modules/ts/include/opencv2/ts/ts_ext.hpp
59index b5cea3e..e5b0b4b 100644 59index b5cea3e46d..e5b0b4ba8c 100644
60--- a/modules/ts/include/opencv2/ts/ts_ext.hpp 60--- a/modules/ts/include/opencv2/ts/ts_ext.hpp
61+++ b/modules/ts/include/opencv2/ts/ts_ext.hpp 61+++ b/modules/ts/include/opencv2/ts/ts_ext.hpp
62@@ -9,7 +9,7 @@ 62@@ -9,7 +9,7 @@
diff --git a/meta-oe/recipes-support/opencv/opencv/CVE-2019-14491.patch b/meta-oe/recipes-support/opencv/opencv/CVE-2019-14491.patch
index 656000a8e1..54a553fb38 100644
--- a/meta-oe/recipes-support/opencv/opencv/CVE-2019-14491.patch
+++ b/meta-oe/recipes-support/opencv/opencv/CVE-2019-14491.patch
@@ -1,4 +1,4 @@
1From 321c74ccd6077bdea1d47450ca4fe955cb5b6330 Mon Sep 17 00:00:00 2001 1From 5a9628c134a7314e10ea0bcc4e789c935251a7f5 Mon Sep 17 00:00:00 2001
2From: Alexander Alekhin <alexander.alekhin@intel.com> 2From: Alexander Alekhin <alexander.alekhin@intel.com>
3Date: Thu, 25 Jul 2019 17:15:59 +0300 3Date: Thu, 25 Jul 2019 17:15:59 +0300
4Subject: [PATCH] objdetect: validate feature rectangle on reading 4Subject: [PATCH] objdetect: validate feature rectangle on reading
@@ -9,39 +9,40 @@ Upstream-Status: Backport [https://github.com/opencv/opencv/commit/ac425f67e4c1d
9Comment: No changes in any hunk 9Comment: No changes in any hunk
10 10
11Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com> 11Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
12
12--- 13---
13 modules/objdetect/src/cascadedetect.cpp | 43 +++++++++++++++++++++---- 14 modules/objdetect/src/cascadedetect.cpp | 43 +++++++++++++++++++++----
14 modules/objdetect/src/cascadedetect.hpp | 6 ++-- 15 modules/objdetect/src/cascadedetect.hpp | 6 ++--
15 2 files changed, 40 insertions(+), 9 deletions(-) 16 2 files changed, 40 insertions(+), 9 deletions(-)
16 17
17diff --git a/modules/objdetect/src/cascadedetect.cpp b/modules/objdetect/src/cascadedetect.cpp 18diff --git a/modules/objdetect/src/cascadedetect.cpp b/modules/objdetect/src/cascadedetect.cpp
18index 4b2078306fe..bd62cd21a1b 100644 19index a1865e9062..b7ef04ea7b 100644
19--- a/modules/objdetect/src/cascadedetect.cpp 20--- a/modules/objdetect/src/cascadedetect.cpp
20+++ b/modules/objdetect/src/cascadedetect.cpp 21+++ b/modules/objdetect/src/cascadedetect.cpp
21@@ -47,6 +47,10 @@ 22@@ -46,6 +46,10 @@
22 #include "opencv2/objdetect/objdetect_c.h" 23 #include "cascadedetect.hpp"
23 #include "opencl_kernels_objdetect.hpp" 24 #include "opencl_kernels_objdetect.hpp"
24 25
25+#if defined(_MSC_VER) 26+#if defined(_MSC_VER)
26+# pragma warning(disable:4458) // declaration of 'origWinSize' hides class member 27+# pragma warning(disable:4458) // declaration of 'origWinSize' hides class member
27+#endif 28+#endif
28+ 29+
29 namespace cv 30 namespace cv
30 { 31 {
31 32
32@@ -537,7 +541,7 @@ bool FeatureEvaluator::setImage( InputArray _image, const std::vector<float>& _s 33@@ -536,7 +540,7 @@ bool FeatureEvaluator::setImage( InputArray _image, const std::vector<float>& _s
33 34
34 //---------------------------------------------- HaarEvaluator --------------------------------------- 35 //---------------------------------------------- HaarEvaluator ---------------------------------------
35 36
36-bool HaarEvaluator::Feature :: read( const FileNode& node ) 37-bool HaarEvaluator::Feature :: read( const FileNode& node )
37+bool HaarEvaluator::Feature::read(const FileNode& node, const Size& origWinSize) 38+bool HaarEvaluator::Feature::read(const FileNode& node, const Size& origWinSize)
38 { 39 {
39 FileNode rnode = node[CC_RECTS]; 40 FileNode rnode = node[CC_RECTS];
40 FileNodeIterator it = rnode.begin(), it_end = rnode.end(); 41 FileNodeIterator it = rnode.begin(), it_end = rnode.end();
41@@ -549,11 +553,23 @@ bool HaarEvaluator::Feature :: read( const FileNode& node ) 42@@ -548,11 +552,23 @@ bool HaarEvaluator::Feature :: read( const FileNode& node )
42 rect[ri].weight = 0.f; 43 rect[ri].weight = 0.f;
43 } 44 }
44 45
45+ const int W = origWinSize.width; 46+ const int W = origWinSize.width;
46+ const int H = origWinSize.height; 47+ const int H = origWinSize.height;
47+ 48+
@@ -62,10 +63,10 @@ index 4b2078306fe..bd62cd21a1b 100644
62+ CV_CheckLE(rw.r.y + rw.r.height, H, "Invalid HAAR feature"); 63+ CV_CheckLE(rw.r.y + rw.r.height, H, "Invalid HAAR feature");
63+ } 64+ }
64 } 65 }
65 66
66 tilted = (int)node[CC_TILTED] != 0; 67 tilted = (int)node[CC_TILTED] != 0;
67@@ -598,7 +614,7 @@ bool HaarEvaluator::read(const FileNode& node, Size _origWinSize) 68@@ -597,7 +613,7 @@ bool HaarEvaluator::read(const FileNode& node, Size _origWinSize)
68 69
69 for(i = 0; i < n; i++, ++it) 70 for(i = 0; i < n; i++, ++it)
70 { 71 {
71- if(!ff[i].read(*it)) 72- if(!ff[i].read(*it))
@@ -73,9 +74,9 @@ index 4b2078306fe..bd62cd21a1b 100644
73 return false; 74 return false;
74 if( ff[i].tilted ) 75 if( ff[i].tilted )
75 hasTiltedFeatures = true; 76 hasTiltedFeatures = true;
76@@ -759,11 +775,24 @@ int HaarEvaluator::getSquaresOffset() const 77@@ -758,11 +774,24 @@ int HaarEvaluator::getSquaresOffset() const
77 } 78 }
78 79
79 //---------------------------------------------- LBPEvaluator ------------------------------------- 80 //---------------------------------------------- LBPEvaluator -------------------------------------
80-bool LBPEvaluator::Feature :: read(const FileNode& node ) 81-bool LBPEvaluator::Feature :: read(const FileNode& node )
81+bool LBPEvaluator::Feature::read(const FileNode& node, const Size& origWinSize) 82+bool LBPEvaluator::Feature::read(const FileNode& node, const Size& origWinSize)
@@ -98,8 +99,8 @@ index 4b2078306fe..bd62cd21a1b 100644
98+ 99+
99 return true; 100 return true;
100 } 101 }
101 102
102@@ -797,7 +826,7 @@ bool LBPEvaluator::read( const FileNode& node, Size _origWinSize ) 103@@ -796,7 +825,7 @@ bool LBPEvaluator::read( const FileNode& node, Size _origWinSize )
103 std::vector<Feature>& ff = *features; 104 std::vector<Feature>& ff = *features;
104 for(int i = 0; it != it_end; ++it, i++) 105 for(int i = 0; it != it_end; ++it, i++)
105 { 106 {
@@ -108,41 +109,40 @@ index 4b2078306fe..bd62cd21a1b 100644
108 return false; 109 return false;
109 } 110 }
110 nchannels = 1; 111 nchannels = 1;
111@@ -1477,6 +1506,8 @@ bool CascadeClassifierImpl::Data::read(const FileNode &root) 112@@ -1441,6 +1470,8 @@ bool CascadeClassifierImpl::Data::read(const FileNode &root)
112 origWinSize.width = (int)root[CC_WIDTH]; 113 origWinSize.width = (int)root[CC_WIDTH];
113 origWinSize.height = (int)root[CC_HEIGHT]; 114 origWinSize.height = (int)root[CC_HEIGHT];
114 CV_Assert( origWinSize.height > 0 && origWinSize.width > 0 ); 115 CV_Assert( origWinSize.height > 0 && origWinSize.width > 0 );
115+ CV_CheckLE(origWinSize.width, 1000000, "Invalid window size (too large)"); 116+ CV_CheckLE(origWinSize.width, 1000000, "Invalid window size (too large)");
116+ CV_CheckLE(origWinSize.height, 1000000, "Invalid window size (too large)"); 117+ CV_CheckLE(origWinSize.height, 1000000, "Invalid window size (too large)");
117 118
118 // load feature params 119 // load feature params
119 FileNode fn = root[CC_FEATURE_PARAMS]; 120 FileNode fn = root[CC_FEATURE_PARAMS];
120diff --git a/modules/objdetect/src/cascadedetect.hpp b/modules/objdetect/src/cascadedetect.hpp 121diff --git a/modules/objdetect/src/cascadedetect.hpp b/modules/objdetect/src/cascadedetect.hpp
121index f9910530b94..d9a288fcdda 100644 122index a011ed4804..ffc03af841 100644
122--- a/modules/objdetect/src/cascadedetect.hpp 123--- a/modules/objdetect/src/cascadedetect.hpp
123+++ b/modules/objdetect/src/cascadedetect.hpp 124+++ b/modules/objdetect/src/cascadedetect.hpp
124@@ -317,12 +317,12 @@ class HaarEvaluator CV_FINAL : public FeatureEvaluator 125@@ -317,12 +317,12 @@ public:
125 struct Feature 126 struct Feature
126 { 127 {
127 Feature(); 128 Feature();
128- bool read( const FileNode& node ); 129- bool read( const FileNode& node );
129+ bool read(const FileNode& node, const Size& origWinSize); 130+ bool read(const FileNode& node, const Size& origWinSize);
130 131
131 bool tilted; 132 bool tilted;
132 133
133 enum { RECT_NUM = 3 }; 134 enum { RECT_NUM = 3 };
134- struct 135- struct
135+ struct RectWeigth 136+ struct RectWeigth
136 { 137 {
137 Rect r; 138 Rect r;
138 float weight; 139 float weight;
139@@ -412,7 +412,7 @@ class LBPEvaluator CV_FINAL : public FeatureEvaluator 140@@ -412,7 +412,7 @@ public:
140 Feature( int x, int y, int _block_w, int _block_h ) : 141 Feature( int x, int y, int _block_w, int _block_h ) :
141 rect(x, y, _block_w, _block_h) {} 142 rect(x, y, _block_w, _block_h) {}
142 143
143- bool read(const FileNode& node ); 144- bool read(const FileNode& node );
144+ bool read(const FileNode& node, const Size& origWinSize); 145+ bool read(const FileNode& node, const Size& origWinSize);
145 146
146 Rect rect; // weight and height for block 147 Rect rect; // weight and height for block
147 }; 148 };
148
diff --git a/meta-oe/recipes-support/opencv/opencv/CVE-2019-14493.patch b/meta-oe/recipes-support/opencv/opencv/CVE-2019-14493.patch
index 2b5e06f23f..37be12b500 100644
--- a/meta-oe/recipes-support/opencv/opencv/CVE-2019-14493.patch
+++ b/meta-oe/recipes-support/opencv/opencv/CVE-2019-14493.patch
@@ -1,4 +1,4 @@
1From 5691d998ead1d9b0542bcfced36c2dceb3a59023 Mon Sep 17 00:00:00 2001 1From 0d88c87ed94e89af490c3d882597e034422aa4a5 Mon Sep 17 00:00:00 2001
2From: Alexander Alekhin <alexander.alekhin@intel.com> 2From: Alexander Alekhin <alexander.alekhin@intel.com>
3Date: Thu, 25 Jul 2019 15:14:22 +0300 3Date: Thu, 25 Jul 2019 15:14:22 +0300
4Subject: [PATCH] core(persistence): added null ptr checks 4Subject: [PATCH] core(persistence): added null ptr checks
@@ -8,6 +8,7 @@ Upstream-Status: Backport [https://github.com/opencv/opencv/commit/5691d998ead1d
8Comment: No changes in any hunk 8Comment: No changes in any hunk
9 9
10Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com> 10Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
11
11--- 12---
12 modules/core/src/persistence_json.cpp | 12 ++++++++++++ 13 modules/core/src/persistence_json.cpp | 12 ++++++++++++
13 modules/core/src/persistence_xml.cpp | 21 +++++++++++++++++++++ 14 modules/core/src/persistence_xml.cpp | 21 +++++++++++++++++++++
@@ -15,11 +16,11 @@ Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
15 3 files changed, 54 insertions(+) 16 3 files changed, 54 insertions(+)
16 17
17diff --git a/modules/core/src/persistence_json.cpp b/modules/core/src/persistence_json.cpp 18diff --git a/modules/core/src/persistence_json.cpp b/modules/core/src/persistence_json.cpp
18index ae678e1b8b1..89914e6534f 100644 19index ae678e1b8b..89914e6534 100644
19--- a/modules/core/src/persistence_json.cpp 20--- a/modules/core/src/persistence_json.cpp
20+++ b/modules/core/src/persistence_json.cpp 21+++ b/modules/core/src/persistence_json.cpp
21@@ -296,6 +296,8 @@ class JSONParser : public FileStorageParser 22@@ -296,6 +296,8 @@ public:
22 23
23 while ( is_eof == false && is_completed == false ) 24 while ( is_eof == false && is_completed == false )
24 { 25 {
25+ if (!ptr) 26+ if (!ptr)
@@ -27,7 +28,7 @@ index ae678e1b8b1..89914e6534f 100644
27 switch ( *ptr ) 28 switch ( *ptr )
28 { 29 {
29 /* comment */ 30 /* comment */
30@@ -381,6 +383,7 @@ class JSONParser : public FileStorageParser 31@@ -381,6 +383,7 @@ public:
31 if ( is_eof || !is_completed ) 32 if ( is_eof || !is_completed )
32 { 33 {
33 ptr = fs->bufferStart(); 34 ptr = fs->bufferStart();
@@ -35,8 +36,8 @@ index ae678e1b8b1..89914e6534f 100644
35 *ptr = '\0'; 36 *ptr = '\0';
36 fs->setEof(); 37 fs->setEof();
37 if( !is_completed ) 38 if( !is_completed )
38@@ -392,6 +395,9 @@ class JSONParser : public FileStorageParser 39@@ -392,6 +395,9 @@ public:
39 40
40 char* parseKey( char* ptr, FileNode& collection, FileNode& value_placeholder ) 41 char* parseKey( char* ptr, FileNode& collection, FileNode& value_placeholder )
41 { 42 {
42+ if (!ptr) 43+ if (!ptr)
@@ -44,9 +45,9 @@ index ae678e1b8b1..89914e6534f 100644
44+ 45+
45 if( *ptr != '"' ) 46 if( *ptr != '"' )
46 CV_PARSE_ERROR_CPP( "Key must start with \'\"\'" ); 47 CV_PARSE_ERROR_CPP( "Key must start with \'\"\'" );
47 48
48@@ -430,6 +436,9 @@ class JSONParser : public FileStorageParser 49@@ -430,6 +436,9 @@ public:
49 50
50 char* parseValue( char* ptr, FileNode& node ) 51 char* parseValue( char* ptr, FileNode& node )
51 { 52 {
52+ if (!ptr) 53+ if (!ptr)
@@ -55,8 +56,8 @@ index ae678e1b8b1..89914e6534f 100644
55 ptr = skipSpaces( ptr ); 56 ptr = skipSpaces( ptr );
56 if( !ptr || !*ptr ) 57 if( !ptr || !*ptr )
57 CV_PARSE_ERROR_CPP( "Unexpected End-Of-File" ); 58 CV_PARSE_ERROR_CPP( "Unexpected End-Of-File" );
58@@ -817,6 +826,9 @@ class JSONParser : public FileStorageParser 59@@ -817,6 +826,9 @@ public:
59 60
60 bool parse( char* ptr ) 61 bool parse( char* ptr )
61 { 62 {
62+ if (!ptr) 63+ if (!ptr)
@@ -66,21 +67,21 @@ index ae678e1b8b1..89914e6534f 100644
66 if ( !ptr || !*ptr ) 67 if ( !ptr || !*ptr )
67 return false; 68 return false;
68diff --git a/modules/core/src/persistence_xml.cpp b/modules/core/src/persistence_xml.cpp 69diff --git a/modules/core/src/persistence_xml.cpp b/modules/core/src/persistence_xml.cpp
69index fb30d90896e..89876dd3da8 100644 70index fb30d90896..89876dd3da 100644
70--- a/modules/core/src/persistence_xml.cpp 71--- a/modules/core/src/persistence_xml.cpp
71+++ b/modules/core/src/persistence_xml.cpp 72+++ b/modules/core/src/persistence_xml.cpp
72@@ -360,6 +360,9 @@ class XMLParser : public FileStorageParser 73@@ -360,6 +360,9 @@ public:
73 74
74 char* skipSpaces( char* ptr, int mode ) 75 char* skipSpaces( char* ptr, int mode )
75 { 76 {
76+ if (!ptr) 77+ if (!ptr)
77+ CV_PARSE_ERROR_CPP("Invalid input"); 78+ CV_PARSE_ERROR_CPP("Invalid input");
78+ 79+
79 int level = 0; 80 int level = 0;
80 81
81 for(;;) 82 for(;;)
82@@ -441,6 +444,9 @@ class XMLParser : public FileStorageParser 83@@ -441,6 +444,9 @@ public:
83 84
84 char* parseValue( char* ptr, FileNode& node ) 85 char* parseValue( char* ptr, FileNode& node )
85 { 86 {
86+ if (!ptr) 87+ if (!ptr)
@@ -89,7 +90,7 @@ index fb30d90896e..89876dd3da8 100644
89 FileNode new_elem; 90 FileNode new_elem;
90 bool have_space = true; 91 bool have_space = true;
91 int value_type = node.type(); 92 int value_type = node.type();
92@@ -456,6 +462,8 @@ class XMLParser : public FileStorageParser 93@@ -456,6 +462,8 @@ public:
93 (c == '<' && ptr[1] == '!' && ptr[2] == '-') ) 94 (c == '<' && ptr[1] == '!' && ptr[2] == '-') )
94 { 95 {
95 ptr = skipSpaces( ptr, 0 ); 96 ptr = skipSpaces( ptr, 0 );
@@ -98,16 +99,16 @@ index fb30d90896e..89876dd3da8 100644
98 have_space = true; 99 have_space = true;
99 c = *ptr; 100 c = *ptr;
100 } 101 }
101@@ -502,6 +510,8 @@ class XMLParser : public FileStorageParser 102@@ -502,6 +510,8 @@ public:
102 { 103 {
103 ptr = fs->parseBase64( ptr, 0, new_elem); 104 ptr = fs->parseBase64( ptr, 0, new_elem);
104 ptr = skipSpaces( ptr, 0 ); 105 ptr = skipSpaces( ptr, 0 );
105+ if (!ptr) 106+ if (!ptr)
106+ CV_PARSE_ERROR_CPP("Invalid input"); 107+ CV_PARSE_ERROR_CPP("Invalid input");
107 } 108 }
108 109
109 ptr = parseTag( ptr, key2, type_name, tag_type ); 110 ptr = parseTag( ptr, key2, type_name, tag_type );
110@@ -645,6 +655,9 @@ class XMLParser : public FileStorageParser 111@@ -645,6 +655,9 @@ public:
111 char* parseTag( char* ptr, std::string& tag_name, 112 char* parseTag( char* ptr, std::string& tag_name,
112 std::string& type_name, int& tag_type ) 113 std::string& type_name, int& tag_type )
113 { 114 {
@@ -116,8 +117,8 @@ index fb30d90896e..89876dd3da8 100644
116+ 117+
117 if( *ptr == '\0' ) 118 if( *ptr == '\0' )
118 CV_PARSE_ERROR_CPP( "Unexpected end of the stream" ); 119 CV_PARSE_ERROR_CPP( "Unexpected end of the stream" );
119 120
120@@ -702,6 +715,8 @@ class XMLParser : public FileStorageParser 121@@ -702,6 +715,8 @@ public:
121 if( *ptr != '=' ) 122 if( *ptr != '=' )
122 { 123 {
123 ptr = skipSpaces( ptr, CV_XML_INSIDE_TAG ); 124 ptr = skipSpaces( ptr, CV_XML_INSIDE_TAG );
@@ -126,7 +127,7 @@ index fb30d90896e..89876dd3da8 100644
126 if( *ptr != '=' ) 127 if( *ptr != '=' )
127 CV_PARSE_ERROR_CPP( "Attribute name should be followed by \'=\'" ); 128 CV_PARSE_ERROR_CPP( "Attribute name should be followed by \'=\'" );
128 } 129 }
129@@ -740,6 +755,8 @@ class XMLParser : public FileStorageParser 130@@ -740,6 +755,8 @@ public:
130 if( c != '>' ) 131 if( c != '>' )
131 { 132 {
132 ptr = skipSpaces( ptr, CV_XML_INSIDE_TAG ); 133 ptr = skipSpaces( ptr, CV_XML_INSIDE_TAG );
@@ -134,31 +135,31 @@ index fb30d90896e..89876dd3da8 100644
134+ CV_PARSE_ERROR_CPP("Invalid input"); 135+ CV_PARSE_ERROR_CPP("Invalid input");
135 c = *ptr; 136 c = *ptr;
136 } 137 }
137 138
138@@ -781,6 +798,8 @@ class XMLParser : public FileStorageParser 139@@ -781,6 +798,8 @@ public:
139 140
140 // CV_XML_INSIDE_TAG is used to prohibit leading comments 141 // CV_XML_INSIDE_TAG is used to prohibit leading comments
141 ptr = skipSpaces( ptr, CV_XML_INSIDE_TAG ); 142 ptr = skipSpaces( ptr, CV_XML_INSIDE_TAG );
142+ if (!ptr) 143+ if (!ptr)
143+ CV_PARSE_ERROR_CPP("Invalid input"); 144+ CV_PARSE_ERROR_CPP("Invalid input");
144 145
145 if( memcmp( ptr, "<?xml", 5 ) != 0 ) // FIXIT ptr[1..] - out of bounds read without check 146 if( memcmp( ptr, "<?xml", 5 ) != 0 ) // FIXIT ptr[1..] - out of bounds read without check
146 CV_PARSE_ERROR_CPP( "Valid XML should start with \'<?xml ...?>\'" ); 147 CV_PARSE_ERROR_CPP( "Valid XML should start with \'<?xml ...?>\'" );
147@@ -791,6 +810,8 @@ class XMLParser : public FileStorageParser 148@@ -791,6 +810,8 @@ public:
148 while( ptr && *ptr != '\0' ) 149 while( ptr && *ptr != '\0' )
149 { 150 {
150 ptr = skipSpaces( ptr, 0 ); 151 ptr = skipSpaces( ptr, 0 );
151+ if (!ptr) 152+ if (!ptr)
152+ CV_PARSE_ERROR_CPP("Invalid input"); 153+ CV_PARSE_ERROR_CPP("Invalid input");
153 154
154 if( *ptr != '\0' ) 155 if( *ptr != '\0' )
155 { 156 {
156diff --git a/modules/core/src/persistence_yml.cpp b/modules/core/src/persistence_yml.cpp 157diff --git a/modules/core/src/persistence_yml.cpp b/modules/core/src/persistence_yml.cpp
157index 4129ca1dc57..7742e827701 100644 158index 4129ca1dc5..7742e82770 100644
158--- a/modules/core/src/persistence_yml.cpp 159--- a/modules/core/src/persistence_yml.cpp
159+++ b/modules/core/src/persistence_yml.cpp 160+++ b/modules/core/src/persistence_yml.cpp
160@@ -330,6 +330,9 @@ class YAMLParser : public FileStorageParser 161@@ -330,6 +330,9 @@ public:
161 162
162 char* skipSpaces( char* ptr, int min_indent, int max_comment_indent ) 163 char* skipSpaces( char* ptr, int min_indent, int max_comment_indent )
163 { 164 {
164+ if (!ptr) 165+ if (!ptr)
@@ -167,8 +168,8 @@ index 4129ca1dc57..7742e827701 100644
167 for(;;) 168 for(;;)
168 { 169 {
169 while( *ptr == ' ' ) 170 while( *ptr == ' ' )
170@@ -374,6 +377,9 @@ class YAMLParser : public FileStorageParser 171@@ -374,6 +377,9 @@ public:
171 172
172 bool getBase64Row(char* ptr, int indent, char* &beg, char* &end) 173 bool getBase64Row(char* ptr, int indent, char* &beg, char* &end)
173 { 174 {
174+ if (!ptr) 175+ if (!ptr)
@@ -177,8 +178,8 @@ index 4129ca1dc57..7742e827701 100644
177 beg = end = ptr = skipSpaces(ptr, 0, INT_MAX); 178 beg = end = ptr = skipSpaces(ptr, 0, INT_MAX);
178 if (!ptr || !*ptr) 179 if (!ptr || !*ptr)
179 return false; // end of file 180 return false; // end of file
180@@ -394,6 +400,9 @@ class YAMLParser : public FileStorageParser 181@@ -394,6 +400,9 @@ public:
181 182
182 char* parseKey( char* ptr, FileNode& map_node, FileNode& value_placeholder ) 183 char* parseKey( char* ptr, FileNode& map_node, FileNode& value_placeholder )
183 { 184 {
184+ if (!ptr) 185+ if (!ptr)
@@ -186,9 +187,9 @@ index 4129ca1dc57..7742e827701 100644
186+ 187+
187 char c; 188 char c;
188 char *endptr = ptr - 1, *saveptr; 189 char *endptr = ptr - 1, *saveptr;
189 190
190@@ -422,6 +431,9 @@ class YAMLParser : public FileStorageParser 191@@ -422,6 +431,9 @@ public:
191 192
192 char* parseValue( char* ptr, FileNode& node, int min_indent, bool is_parent_flow ) 193 char* parseValue( char* ptr, FileNode& node, int min_indent, bool is_parent_flow )
193 { 194 {
194+ if (!ptr) 195+ if (!ptr)
@@ -197,35 +198,35 @@ index 4129ca1dc57..7742e827701 100644
197 char* endptr = 0; 198 char* endptr = 0;
198 char c = ptr[0], d = ptr[1]; 199 char c = ptr[0], d = ptr[1];
199 int value_type = FileNode::NONE; 200 int value_type = FileNode::NONE;
200@@ -508,6 +520,8 @@ class YAMLParser : public FileStorageParser 201@@ -508,6 +520,8 @@ public:
201 202
202 *endptr = d; 203 *endptr = d;
203 ptr = skipSpaces( endptr, min_indent, INT_MAX ); 204 ptr = skipSpaces( endptr, min_indent, INT_MAX );
204+ if (!ptr) 205+ if (!ptr)
205+ CV_PARSE_ERROR_CPP("Invalid input"); 206+ CV_PARSE_ERROR_CPP("Invalid input");
206 207
207 c = *ptr; 208 c = *ptr;
208 209
209@@ -634,6 +648,8 @@ class YAMLParser : public FileStorageParser 210@@ -634,6 +648,8 @@ public:
210 FileNode elem; 211 FileNode elem;
211 212
212 ptr = skipSpaces( ptr, new_min_indent, INT_MAX ); 213 ptr = skipSpaces( ptr, new_min_indent, INT_MAX );
213+ if (!ptr) 214+ if (!ptr)
214+ CV_PARSE_ERROR_CPP("Invalid input"); 215+ CV_PARSE_ERROR_CPP("Invalid input");
215 if( *ptr == '}' || *ptr == ']' ) 216 if( *ptr == '}' || *ptr == ']' )
216 { 217 {
217 if( *ptr != d ) 218 if( *ptr != d )
218@@ -647,6 +663,8 @@ class YAMLParser : public FileStorageParser 219@@ -647,6 +663,8 @@ public:
219 if( *ptr != ',' ) 220 if( *ptr != ',' )
220 CV_PARSE_ERROR_CPP( "Missing , between the elements" ); 221 CV_PARSE_ERROR_CPP( "Missing , between the elements" );
221 ptr = skipSpaces( ptr + 1, new_min_indent, INT_MAX ); 222 ptr = skipSpaces( ptr + 1, new_min_indent, INT_MAX );
222+ if (!ptr) 223+ if (!ptr)
223+ CV_PARSE_ERROR_CPP("Invalid input"); 224+ CV_PARSE_ERROR_CPP("Invalid input");
224 } 225 }
225 226
226 if( struct_type == FileNode::MAP ) 227 if( struct_type == FileNode::MAP )
227@@ -746,6 +764,9 @@ class YAMLParser : public FileStorageParser 228@@ -746,6 +764,9 @@ public:
228 229
229 bool parse( char* ptr ) 230 bool parse( char* ptr )
230 { 231 {
231+ if (!ptr) 232+ if (!ptr)
@@ -234,4 +235,3 @@ index 4129ca1dc57..7742e827701 100644
234 bool first = true; 235 bool first = true;
235 bool ok = true; 236 bool ok = true;
236 FileNode root_collection(fs->getFS(), 0, 0); 237 FileNode root_collection(fs->getFS(), 0, 0);
237
diff --git a/meta-oe/recipes-support/opencv/opencv/CVE-2019-15939.patch b/meta-oe/recipes-support/opencv/opencv/CVE-2019-15939.patch
index e9f8514cbe..ad61d7c231 100644
--- a/meta-oe/recipes-support/opencv/opencv/CVE-2019-15939.patch
+++ b/meta-oe/recipes-support/opencv/opencv/CVE-2019-15939.patch
@@ -1,4 +1,4 @@
1From 5a497077f109d543ab86dfdf8add1c76c0e47d29 Mon Sep 17 00:00:00 2001 1From 384c5fa5f09aec5512343340fe65ccaaf83dfc48 Mon Sep 17 00:00:00 2001
2From: Alexander Alekhin <alexander.alekhin@intel.com> 2From: Alexander Alekhin <alexander.alekhin@intel.com>
3Date: Fri, 23 Aug 2019 16:14:53 +0300 3Date: Fri, 23 Aug 2019 16:14:53 +0300
4Subject: [PATCH] objdetect: add input check in HOG detector 4Subject: [PATCH] objdetect: add input check in HOG detector
@@ -8,24 +8,25 @@ Upstream-Status: Backport [https://github.com/opencv/opencv/commit/5a497077f109d
8Comment: No changes in any hunk 8Comment: No changes in any hunk
9 9
10Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com> 10Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
11
11--- 12---
12 modules/objdetect/src/hog.cpp | 19 ++++++++++++------- 13 modules/objdetect/src/hog.cpp | 19 ++++++++++++-------
13 1 file changed, 12 insertions(+), 7 deletions(-) 14 1 file changed, 12 insertions(+), 7 deletions(-)
14 15
15diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp 16diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp
16index 9524851eebb..378bab30876 100644 17index e3e43bb86e..af814658fe 100644
17--- a/modules/objdetect/src/hog.cpp 18--- a/modules/objdetect/src/hog.cpp
18+++ b/modules/objdetect/src/hog.cpp 19+++ b/modules/objdetect/src/hog.cpp
19@@ -68,6 +68,7 @@ enum {DESCR_FORMAT_COL_BY_COL, DESCR_FORMAT_ROW_BY_ROW}; 20@@ -65,6 +65,7 @@ namespace cv
20 21
21 static int numPartsWithin(int size, int part_size, int stride) 22 static int numPartsWithin(int size, int part_size, int stride)
22 { 23 {
23+ CV_Assert(stride != 0); 24+ CV_Assert(stride != 0);
24 return (size - part_size + stride) / stride; 25 return (size - part_size + stride) / stride;
25 } 26 }
26 27
27@@ -80,13 +81,17 @@ static Size numPartsWithin(cv::Size size, cv::Size part_size, 28@@ -77,13 +78,17 @@ static Size numPartsWithin(cv::Size size, cv::Size part_size,
28 29
29 static size_t getBlockHistogramSize(Size block_size, Size cell_size, int nbins) 30 static size_t getBlockHistogramSize(Size block_size, Size cell_size, int nbins)
30 { 31 {
31+ CV_Assert(!cell_size.empty()); 32+ CV_Assert(!cell_size.empty());
@@ -34,7 +35,7 @@ index 9524851eebb..378bab30876 100644
34+ block_size.height / cell_size.height); 35+ block_size.height / cell_size.height);
35 return (size_t)(nbins * cells_per_block.area()); 36 return (size_t)(nbins * cells_per_block.area());
36 } 37 }
37 38
38 size_t HOGDescriptor::getDescriptorSize() const 39 size_t HOGDescriptor::getDescriptorSize() const
39 { 40 {
40+ CV_Assert(!cellSize.empty()); 41+ CV_Assert(!cellSize.empty());
@@ -43,7 +44,7 @@ index 9524851eebb..378bab30876 100644
43 CV_Assert(blockSize.width % cellSize.width == 0 && 44 CV_Assert(blockSize.width % cellSize.width == 0 &&
44 blockSize.height % cellSize.height == 0); 45 blockSize.height % cellSize.height == 0);
45 CV_Assert((winSize.width - blockSize.width) % blockStride.width == 0 && 46 CV_Assert((winSize.width - blockSize.width) % blockStride.width == 0 &&
46@@ -144,20 +149,20 @@ bool HOGDescriptor::read(FileNode& obj) 47@@ -141,20 +146,20 @@ bool HOGDescriptor::read(FileNode& obj)
47 if( !obj.isMap() ) 48 if( !obj.isMap() )
48 return false; 49 return false;
49 FileNodeIterator it = obj["winSize"].begin(); 50 FileNodeIterator it = obj["winSize"].begin();
@@ -70,4 +71,3 @@ index 9524851eebb..378bab30876 100644
70 if (obj["signedGradient"].empty()) 71 if (obj["signedGradient"].empty())
71 signedGradient = false; 72 signedGradient = false;
72 else 73 else
73
diff --git a/meta-oe/recipes-support/opencv/opencv/CVE-2019-19624.patch b/meta-oe/recipes-support/opencv/opencv/CVE-2019-19624.patch
index 79f8514bdd..3510e1eb98 100644
--- a/meta-oe/recipes-support/opencv/opencv/CVE-2019-19624.patch
+++ b/meta-oe/recipes-support/opencv/opencv/CVE-2019-19624.patch
@@ -1,4 +1,4 @@
1From d1615ba11a93062b1429fce9f0f638d1572d3418 Mon Sep 17 00:00:00 2001 1From 34195a57528a3f2c807bc3eeb8c934b8ea8289bd Mon Sep 17 00:00:00 2001
2From: Thang Tran <TranKimThang279@gmail.com> 2From: Thang Tran <TranKimThang279@gmail.com>
3Date: Mon, 27 May 2019 08:18:26 +0200 3Date: Mon, 27 May 2019 08:18:26 +0200
4Subject: [PATCH] video:fixed DISOpticalFlow segfault from small img 4Subject: [PATCH] video:fixed DISOpticalFlow segfault from small img
@@ -8,13 +8,14 @@ Upstream-Status: Backport [https://github.com/opencv/opencv/commit/d1615ba11a930
8Comment: No changes in any hunk 8Comment: No changes in any hunk
9 9
10Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com> 10Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
11
11--- 12---
12 modules/video/src/dis_flow.cpp | 67 ++++++++++++++++++++++++- 13 modules/video/src/dis_flow.cpp | 67 ++++++++++++++++++++++++-
13 modules/video/test/test_OF_accuracy.cpp | 28 +++++++++++ 14 modules/video/test/test_OF_accuracy.cpp | 28 +++++++++++
14 2 files changed, 93 insertions(+), 2 deletions(-) 15 2 files changed, 93 insertions(+), 2 deletions(-)
15 16
16diff --git a/modules/video/src/dis_flow.cpp b/modules/video/src/dis_flow.cpp 17diff --git a/modules/video/src/dis_flow.cpp b/modules/video/src/dis_flow.cpp
17index a453d8b2b51..806d6f1ddaf 100644 18index b86df1564b..adafcc92d8 100644
18--- a/modules/video/src/dis_flow.cpp 19--- a/modules/video/src/dis_flow.cpp
19+++ b/modules/video/src/dis_flow.cpp 20+++ b/modules/video/src/dis_flow.cpp
20@@ -140,6 +140,8 @@ class DISOpticalFlowImpl CV_FINAL : public DISOpticalFlow 21@@ -140,6 +140,8 @@ class DISOpticalFlowImpl CV_FINAL : public DISOpticalFlow
@@ -23,13 +24,13 @@ index a453d8b2b51..806d6f1ddaf 100644
23 Mat &I0y); 24 Mat &I0y);
24+ int autoSelectCoarsestScale(int img_width); 25+ int autoSelectCoarsestScale(int img_width);
25+ void autoSelectPatchSizeAndScales(int img_width); 26+ void autoSelectPatchSizeAndScales(int img_width);
26 27
27 struct PatchInverseSearch_ParBody : public ParallelLoopBody 28 struct PatchInverseSearch_ParBody : public ParallelLoopBody
28 { 29 {
29@@ -435,6 +437,44 @@ void DISOpticalFlowImpl::precomputeStructureTensor(Mat &dst_I0xx, Mat &dst_I0yy, 30@@ -435,6 +437,44 @@ void DISOpticalFlowImpl::precomputeStructureTensor(Mat &dst_I0xx, Mat &dst_I0yy,
30 } 31 }
31 } 32 }
32 33
33+int DISOpticalFlowImpl::autoSelectCoarsestScale(int img_width) 34+int DISOpticalFlowImpl::autoSelectCoarsestScale(int img_width)
34+{ 35+{
35+ const int fratio = 5; 36+ const int fratio = 5;
@@ -71,14 +72,14 @@ index a453d8b2b51..806d6f1ddaf 100644
71 DISOpticalFlowImpl::PatchInverseSearch_ParBody::PatchInverseSearch_ParBody(DISOpticalFlowImpl &_dis, int _nstripes, 72 DISOpticalFlowImpl::PatchInverseSearch_ParBody::PatchInverseSearch_ParBody(DISOpticalFlowImpl &_dis, int _nstripes,
72 int _hs, Mat &dst_Sx, Mat &dst_Sy, 73 int _hs, Mat &dst_Sx, Mat &dst_Sy,
73 Mat &src_Ux, Mat &src_Uy, Mat &_I0, Mat &_I1, 74 Mat &src_Ux, Mat &src_Uy, Mat &_I0, Mat &_I1,
74@@ -1318,9 +1358,20 @@ bool DISOpticalFlowImpl::ocl_calc(InputArray I0, InputArray I1, InputOutputArray 75@@ -1313,9 +1353,20 @@ bool DISOpticalFlowImpl::ocl_calc(InputArray I0, InputArray I1, InputOutputArray
75 else 76 else
76 flow.create(I1Mat.size(), CV_32FC2); 77 flow.create(I1Mat.size(), CV_32FC2);
77 UMat &u_flowMat = flow.getUMatRef(); 78 UMat &u_flowMat = flow.getUMatRef();
78- coarsest_scale = min((int)(log(max(I0Mat.cols, I0Mat.rows) / (4.0 * patch_size)) / log(2.0) + 0.5), /* Original code serach for maximal movement of width/4 */ 79- coarsest_scale = min((int)(log(max(I0Mat.cols, I0Mat.rows) / (4.0 * patch_size)) / log(2.0) + 0.5), /* Original code serach for maximal movement of width/4 */
79+ coarsest_scale = min((int)(log(max(I0Mat.cols, I0Mat.rows) / (4.0 * patch_size)) / log(2.0) + 0.5), /* Original code search for maximal movement of width/4 */ 80+ coarsest_scale = min((int)(log(max(I0Mat.cols, I0Mat.rows) / (4.0 * patch_size)) / log(2.0) + 0.5), /* Original code search for maximal movement of width/4 */
80 (int)(log(min(I0Mat.cols, I0Mat.rows) / patch_size) / log(2.0))); /* Deepest pyramid level greater or equal than patch*/ 81 (int)(log(min(I0Mat.cols, I0Mat.rows) / patch_size) / log(2.0))); /* Deepest pyramid level greater or equal than patch*/
81 82
82+ if (coarsest_scale<0) 83+ if (coarsest_scale<0)
83+ CV_Error(cv::Error::StsBadSize, "The input image must have either width or height >= 12"); 84+ CV_Error(cv::Error::StsBadSize, "The input image must have either width or height >= 12");
84+ 85+
@@ -93,7 +94,7 @@ index a453d8b2b51..806d6f1ddaf 100644
93 ocl_prepareBuffers(I0Mat, I1Mat, u_flowMat, use_input_flow); 94 ocl_prepareBuffers(I0Mat, I1Mat, u_flowMat, use_input_flow);
94 u_Ux[coarsest_scale].setTo(0.0f); 95 u_Ux[coarsest_scale].setTo(0.0f);
95 u_Uy[coarsest_scale].setTo(0.0f); 96 u_Uy[coarsest_scale].setTo(0.0f);
96@@ -1385,8 +1436,20 @@ void DISOpticalFlowImpl::calc(InputArray I0, InputArray I1, InputOutputArray flo 97@@ -1380,8 +1431,20 @@ void DISOpticalFlowImpl::calc(InputArray I0, InputArray I1, InputOutputArray flo
97 else 98 else
98 flow.create(I1Mat.size(), CV_32FC2); 99 flow.create(I1Mat.size(), CV_32FC2);
99 Mat flowMat = flow.getMat(); 100 Mat flowMat = flow.getMat();
@@ -113,16 +114,16 @@ index a453d8b2b51..806d6f1ddaf 100644
113+ } 114+ }
114+ 115+
115 int num_stripes = getNumThreads(); 116 int num_stripes = getNumThreads();
116 117
117 prepareBuffers(I0Mat, I1Mat, flowMat, use_input_flow); 118 prepareBuffers(I0Mat, I1Mat, flowMat, use_input_flow);
118diff --git a/modules/video/test/test_OF_accuracy.cpp b/modules/video/test/test_OF_accuracy.cpp 119diff --git a/modules/video/test/test_OF_accuracy.cpp b/modules/video/test/test_OF_accuracy.cpp
119index affbab65866..b99ffce2a8b 100644 120index affbab6586..b99ffce2a8 100644
120--- a/modules/video/test/test_OF_accuracy.cpp 121--- a/modules/video/test/test_OF_accuracy.cpp
121+++ b/modules/video/test/test_OF_accuracy.cpp 122+++ b/modules/video/test/test_OF_accuracy.cpp
122@@ -121,6 +121,34 @@ TEST(DenseOpticalFlow_DIS, ReferenceAccuracy) 123@@ -121,6 +121,34 @@ TEST(DenseOpticalFlow_DIS, ReferenceAccuracy)
123 } 124 }
124 } 125 }
125 126
126+TEST(DenseOpticalFlow_DIS, InvalidImgSize_CoarsestLevelLessThanZero) 127+TEST(DenseOpticalFlow_DIS, InvalidImgSize_CoarsestLevelLessThanZero)
127+{ 128+{
128+ cv::Ptr<cv::DISOpticalFlow> of = cv::DISOpticalFlow::create(); 129+ cv::Ptr<cv::DISOpticalFlow> of = cv::DISOpticalFlow::create();
@@ -154,4 +155,3 @@ index affbab65866..b99ffce2a8b 100644
154 TEST(DenseOpticalFlow_VariationalRefinement, ReferenceAccuracy) 155 TEST(DenseOpticalFlow_VariationalRefinement, ReferenceAccuracy)
155 { 156 {
156 Mat frame1, frame2, GT; 157 Mat frame1, frame2, GT;
157
diff --git a/meta-oe/recipes-support/opencv/opencv/download.patch b/meta-oe/recipes-support/opencv/opencv/download.patch
index fa8db88078..ae01a5edcd 100644
--- a/meta-oe/recipes-support/opencv/opencv/download.patch
+++ b/meta-oe/recipes-support/opencv/opencv/download.patch
@@ -1,3 +1,8 @@
1From 3b1a69503dea2075d51655a0cea5369c88a67632 Mon Sep 17 00:00:00 2001
2From: Ross Burton <ross.burton@intel.com>
3Date: Thu, 9 Jan 2020 16:24:24 +0000
4Subject: [PATCH] opencv: abort configure if we need to download
5
1This CMake module will download files during do_configure. This is bad as it 6This CMake module will download files during do_configure. This is bad as it
2means we can't do offline builds. 7means we can't do offline builds.
3 8
@@ -6,6 +11,10 @@ Add an option to disallow downloads by emitting a fatal error.
6Upstream-Status: Pending 11Upstream-Status: Pending
7Signed-off-by: Ross Burton <ross.burton@intel.com> 12Signed-off-by: Ross Burton <ross.burton@intel.com>
8 13
14---
15 cmake/OpenCVDownload.cmake | 6 ++++++
16 1 file changed, 6 insertions(+)
17
9diff --git a/cmake/OpenCVDownload.cmake b/cmake/OpenCVDownload.cmake 18diff --git a/cmake/OpenCVDownload.cmake b/cmake/OpenCVDownload.cmake
10index cdc47ad2cb..74573f45a2 100644 19index cdc47ad2cb..74573f45a2 100644
11--- a/cmake/OpenCVDownload.cmake 20--- a/cmake/OpenCVDownload.cmake