Merge pull request #2272 from Exiv2/mergify/bp/main/pr-2269
Replace assert with enforce (backport #2269)
This commit is contained in:
commit
a22aea0a96
@ -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);
|
||||
|
||||
BIN
test/data/issue_2268_poc.jp2
Normal file
BIN
test/data/issue_2268_poc.jp2
Normal file
Binary file not shown.
13
tests/bugfixes/github/test_issue_2268.py
Normal file
13
tests/bugfixes/github/test_issue_2268.py
Normal 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
|
||||
@ -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",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user