Merge pull request #2272 from Exiv2/mergify/bp/main/pr-2269

Replace assert with enforce (backport #2269)
This commit is contained in:
Kevin Backhouse 2022-07-08 10:30:51 +01:00 committed by GitHub
commit a22aea0a96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 1 deletions

View File

@ -475,7 +475,7 @@ void Jp2Image::printStructure(std::ostream& out, PrintStructureOption option, in
}
if (subBox.type == kJp2BoxTypeImageHeader) {
assert(subBox.length == 22);
enforce(subBox.length == 22, ErrorCode::kerCorruptedMetadata);
// height (4), width (4), componentsCount (2), bpc (1)
auto compressionType = data.read_uint8(11);
auto unkC = data.read_uint8(12);

Binary file not shown.

View File

@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
from system_tests import CaseMeta, check_no_ASAN_UBSAN_errors
class issue_2268_jp2_assert(metaclass=CaseMeta):
url = "https://github.com/Exiv2/exiv2/issues/2268"
filename = "$data_path/issue_2268_poc.jp2"
commands = ["$exiv2 -pS $filename"]
retval = [1]
stderr = ["""$exiv2_exception_message $filename:
$kerCorruptedMetadata
"""]
compare_stdout = check_no_ASAN_UBSAN_errors

View File

@ -91,6 +91,7 @@ def get_valid_files(data_dir):
"issue_960.poc.webp",
"issue_2160_poc.jpg",
"issue_2178_poc.jp2",
"issue_2268_poc.jp2",
"issue_ghsa_583f_w9pm_99r2_poc.jp2",
"issue_ghsa_7569_phvm_vwc2_poc.jp2",
"issue_ghsa_mxw9_qx4c_6m8v_poc.jp2",