diff options
| -rw-r--r-- | meta-oe/recipes-support/opencv/opencv/CVE-2023-2617.patch | 88 | ||||
| -rw-r--r-- | meta-oe/recipes-support/opencv/opencv_4.8.0.bb (renamed from meta-oe/recipes-support/opencv/opencv_4.7.0.bb) | 9 |
2 files changed, 4 insertions, 93 deletions
diff --git a/meta-oe/recipes-support/opencv/opencv/CVE-2023-2617.patch b/meta-oe/recipes-support/opencv/opencv/CVE-2023-2617.patch deleted file mode 100644 index 92c096e29c..0000000000 --- a/meta-oe/recipes-support/opencv/opencv/CVE-2023-2617.patch +++ /dev/null | |||
| @@ -1,88 +0,0 @@ | |||
| 1 | commit ccc277247ac1a7aef0a90353edcdec35fbc5903c | ||
| 2 | Author: Nano <nanoapezlk@gmail.com> | ||
| 3 | Date: Wed Apr 26 15:09:52 2023 +0800 | ||
| 4 | |||
| 5 | fix(wechat_qrcode): Init nBytes after the count value is determined (#3480) | ||
| 6 | |||
| 7 | * fix(wechat_qrcode): Initialize nBytes after the count value is determined | ||
| 8 | |||
| 9 | * fix(wechat_qrcode): Incorrect count data repair | ||
| 10 | |||
| 11 | * chore: format expr | ||
| 12 | |||
| 13 | * fix(wechat_qrcode): Avoid null pointer exception | ||
| 14 | |||
| 15 | * fix(wechat_qrcode): return when bytes_ is empty | ||
| 16 | |||
| 17 | * test(wechat_qrcode): add test case | ||
| 18 | |||
| 19 | --------- | ||
| 20 | |||
| 21 | Co-authored-by: GZTime <Time.GZ@outlook.com> | ||
| 22 | |||
| 23 | CVE: CVE-2023-2617 | ||
| 24 | |||
| 25 | Upstream-Status: Backport [https://github.com/opencv/opencv_contrib/commit/ccc277247ac1a7aef0a90353edcdec35fbc5903c] | ||
| 26 | |||
| 27 | Signed-off-by: Soumya <soumya.sambu@windriver.com> | ||
| 28 | --- | ||
| 29 | |||
| 30 | diff --git a/modules/wechat_qrcode/src/zxing/qrcode/decoder/decoded_bit_stream_parser.cpp b/modules/wechat_qrcode/src/zxing/qrcode/decoder/decoded_bit_stream_parser.cpp | ||
| 31 | index 05de793c..b3a0a69c 100644 | ||
| 32 | --- a/modules/wechat_qrcode/src/zxing/qrcode/decoder/decoded_bit_stream_parser.cpp | ||
| 33 | +++ b/modules/wechat_qrcode/src/zxing/qrcode/decoder/decoded_bit_stream_parser.cpp | ||
| 34 | @@ -65,7 +65,8 @@ void DecodedBitStreamParser::append(std::string& result, string const& in, | ||
| 35 | |||
| 36 | void DecodedBitStreamParser::append(std::string& result, const char* bufIn, size_t nIn, | ||
| 37 | ErrorHandler& err_handler) { | ||
| 38 | - if (err_handler.ErrCode()) return; | ||
| 39 | + // avoid null pointer exception | ||
| 40 | + if (err_handler.ErrCode() || bufIn == nullptr) return; | ||
| 41 | #ifndef NO_ICONV_INSIDE | ||
| 42 | if (nIn == 0) { | ||
| 43 | return; | ||
| 44 | @@ -190,16 +191,20 @@ void DecodedBitStreamParser::decodeByteSegment(Ref<BitSource> bits_, string& res | ||
| 45 | CharacterSetECI* currentCharacterSetECI, | ||
| 46 | ArrayRef<ArrayRef<char> >& byteSegments, | ||
| 47 | ErrorHandler& err_handler) { | ||
| 48 | - int nBytes = count; | ||
| 49 | BitSource& bits(*bits_); | ||
| 50 | // Don't crash trying to read more bits than we have available. | ||
| 51 | int available = bits.available(); | ||
| 52 | // try to repair count data if count data is invalid | ||
| 53 | if (count * 8 > available) { | ||
| 54 | - count = (available + 7 / 8); | ||
| 55 | + count = (available + 7) / 8; | ||
| 56 | } | ||
| 57 | + size_t nBytes = count; | ||
| 58 | + | ||
| 59 | + ArrayRef<char> bytes_(nBytes); | ||
| 60 | + // issue https://github.com/opencv/opencv_contrib/issues/3478 | ||
| 61 | + if (bytes_->empty()) | ||
| 62 | + return; | ||
| 63 | |||
| 64 | - ArrayRef<char> bytes_(count); | ||
| 65 | char* readBytes = &(*bytes_)[0]; | ||
| 66 | for (int i = 0; i < count; i++) { | ||
| 67 | // readBytes[i] = (char) bits.readBits(8); | ||
| 68 | diff --git a/modules/wechat_qrcode/test/test_qrcode.cpp b/modules/wechat_qrcode/test/test_qrcode.cpp | ||
| 69 | index d59932b8..ec2559b0 100644 | ||
| 70 | --- a/modules/wechat_qrcode/test/test_qrcode.cpp | ||
| 71 | +++ b/modules/wechat_qrcode/test/test_qrcode.cpp | ||
| 72 | @@ -455,5 +455,16 @@ TEST_P(Objdetect_QRCode_Easy_Multi, regression) { | ||
| 73 | std::string qrcode_model_path[] = {"", "dnn/wechat_2021-01"}; | ||
| 74 | INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_Easy_Multi, testing::ValuesIn(qrcode_model_path)); | ||
| 75 | |||
| 76 | +TEST(Objdetect_QRCode_bug, issue_3478) { | ||
| 77 | + auto detector = wechat_qrcode::WeChatQRCode(); | ||
| 78 | + std::string image_path = findDataFile("qrcode/issue_3478.png"); | ||
| 79 | + Mat src = imread(image_path, IMREAD_GRAYSCALE); | ||
| 80 | + ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path; | ||
| 81 | + std::vector<std::string> outs = detector.detectAndDecode(src); | ||
| 82 | + ASSERT_EQ(1, (int) outs.size()); | ||
| 83 | + ASSERT_EQ(16, (int) outs[0].size()); | ||
| 84 | + ASSERT_EQ("KFCVW50 ", outs[0]); | ||
| 85 | +} | ||
| 86 | + | ||
| 87 | } // namespace | ||
| 88 | } // namespace opencv_test | ||
diff --git a/meta-oe/recipes-support/opencv/opencv_4.7.0.bb b/meta-oe/recipes-support/opencv/opencv_4.8.0.bb index a1fbaaa091..9564bbbe9d 100644 --- a/meta-oe/recipes-support/opencv/opencv_4.7.0.bb +++ b/meta-oe/recipes-support/opencv/opencv_4.8.0.bb | |||
| @@ -10,8 +10,8 @@ ARM_INSTRUCTION_SET:armv5 = "arm" | |||
| 10 | 10 | ||
| 11 | DEPENDS = "libtool swig-native bzip2 zlib glib-2.0 libwebp" | 11 | DEPENDS = "libtool swig-native bzip2 zlib glib-2.0 libwebp" |
| 12 | 12 | ||
| 13 | SRCREV_opencv = "725e440d278aca07d35a5e8963ef990572b07316" | 13 | SRCREV_opencv = "f9a59f2592993d3dcc080e495f4f5e02dd8ec7ef" |
| 14 | SRCREV_contrib = "e247b680a6bd396f110274b6c214406a93171350" | 14 | SRCREV_contrib = "f10c84d48b0714f2b408c9e5cccfac1277c8e6cc" |
| 15 | SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26" | 15 | SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26" |
| 16 | SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d" | 16 | SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d" |
| 17 | SRCREV_face = "8afa57abc8229d611c4937165d20e2a2d9fc5a12" | 17 | SRCREV_face = "8afa57abc8229d611c4937165d20e2a2d9fc5a12" |
| @@ -19,8 +19,8 @@ SRCREV_wechat-qrcode = "a8b69ccc738421293254aec5ddb38bd523503252" | |||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg" | 21 | SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg" |
| 22 | SRC_URI = "git://github.com/opencv/opencv.git;name=opencv;branch=master;protocol=https \ | 22 | SRC_URI = "git://github.com/opencv/opencv.git;name=opencv;branch=4.x;protocol=https \ |
| 23 | git://github.com/opencv/opencv_contrib.git;destsuffix=git/contrib;name=contrib;branch=master;protocol=https \ | 23 | git://github.com/opencv/opencv_contrib.git;destsuffix=git/contrib;name=contrib;branch=4.x;protocol=https \ |
| 24 | git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=git/boostdesc;name=boostdesc;protocol=https \ | 24 | git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=git/boostdesc;name=boostdesc;protocol=https \ |
| 25 | git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=git/vgg;name=vgg;protocol=https \ | 25 | git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=git/vgg;name=vgg;protocol=https \ |
| 26 | git://github.com/opencv/opencv_3rdparty.git;branch=contrib_face_alignment_20170818;destsuffix=git/face;name=face;protocol=https \ | 26 | git://github.com/opencv/opencv_3rdparty.git;branch=contrib_face_alignment_20170818;destsuffix=git/face;name=face;protocol=https \ |
| @@ -31,7 +31,6 @@ SRC_URI = "git://github.com/opencv/opencv.git;name=opencv;branch=master;protocol | |||
| 31 | file://download.patch \ | 31 | file://download.patch \ |
| 32 | file://0001-Make-ts-module-external.patch \ | 32 | file://0001-Make-ts-module-external.patch \ |
| 33 | file://0008-Do-not-embed-build-directory-in-binaries.patch \ | 33 | file://0008-Do-not-embed-build-directory-in-binaries.patch \ |
| 34 | file://CVE-2023-2617.patch;patchdir=contrib \ | ||
| 35 | " | 34 | " |
| 36 | SRC_URI:append:riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patchdir=contrib" | 35 | SRC_URI:append:riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patchdir=contrib" |
| 37 | 36 | ||
