Skip to content

Commit a22aea0

Browse files
Merge pull request #2272 from Exiv2/mergify/bp/main/pr-2269
Replace assert with enforce (backport #2269)
2 parents 75c53ea + 58cef75 commit a22aea0

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

src/jp2image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ void Jp2Image::printStructure(std::ostream& out, PrintStructureOption option, in
475475
}
476476

477477
if (subBox.type == kJp2BoxTypeImageHeader) {
478-
assert(subBox.length == 22);
478+
enforce(subBox.length == 22, ErrorCode::kerCorruptedMetadata);
479479
// height (4), width (4), componentsCount (2), bpc (1)
480480
auto compressionType = data.read_uint8(11);
481481
auto unkC = data.read_uint8(12);

test/data/issue_2268_poc.jp2

97 Bytes
Binary file not shown.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from system_tests import CaseMeta, check_no_ASAN_UBSAN_errors
4+
5+
class issue_2268_jp2_assert(metaclass=CaseMeta):
6+
url = "https://github.com/Exiv2/exiv2/issues/2268"
7+
filename = "$data_path/issue_2268_poc.jp2"
8+
commands = ["$exiv2 -pS $filename"]
9+
retval = [1]
10+
stderr = ["""$exiv2_exception_message $filename:
11+
$kerCorruptedMetadata
12+
"""]
13+
compare_stdout = check_no_ASAN_UBSAN_errors

tests/regression_tests/test_regression_allfiles.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def get_valid_files(data_dir):
9191
"issue_960.poc.webp",
9292
"issue_2160_poc.jpg",
9393
"issue_2178_poc.jp2",
94+
"issue_2268_poc.jp2",
9495
"issue_ghsa_583f_w9pm_99r2_poc.jp2",
9596
"issue_ghsa_7569_phvm_vwc2_poc.jp2",
9697
"issue_ghsa_mxw9_qx4c_6m8v_poc.jp2",

0 commit comments

Comments
 (0)