diff --git a/test/data/issue_1812_poc.jp2 b/test/data/issue_1812_poc.jp2 new file mode 100644 index 00000000..af82b32c Binary files /dev/null and b/test/data/issue_1812_poc.jp2 differ diff --git a/tests/bugfixes/github/test_issue_1812.py b/tests/bugfixes/github/test_issue_1812.py new file mode 100644 index 00000000..0385199a --- /dev/null +++ b/tests/bugfixes/github/test_issue_1812.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +from system_tests import CaseMeta, path, check_no_ASAN_UBSAN_errors + + +class OutOfMemoryInJp2ImageReadMetadata(metaclass=CaseMeta): + """ + Regression test for the bug described in: + https://github.com/Exiv2/exiv2/issues/1812 + + Due to a missing bounds check, this test triggers a 4GB memory + allocation. So the test will fail with a std::bad_alloc exception + if less than 4GB is available. On Linux, you can use `ulimit -v + 4000000` to reduce the available memory to slightly less than 4GB. + """ + url = "https://github.com/Exiv2/exiv2/issues/1812" + + filename = path("$data_path/issue_1812_poc.jp2") + commands = ["$exiv2 $filename"] + stdout = [""] + stderr = [ + """$exiv2_exception_message $filename: +$kerInputDataReadFailed +"""] + retval = [1]