diff --git a/src/tags_int.cpp b/src/tags_int.cpp index a81a1ad3..aa1d1de3 100644 --- a/src/tags_int.cpp +++ b/src/tags_int.cpp @@ -2519,7 +2519,7 @@ std::ostream& printDegrees(std::ostream& os, const Value& value, const ExifData* const int32_t mm = min.first / min.second; const int32_t rem = min.first % min.second; if ((min.second > 1) && (rem > 0)) { - if ((sec.first == 0) && (sec.second == 1)) { + if ((sec.first == 0) && (sec.second == 1) && (rem <= std::numeric_limits::max() / 60)) { sec.first = 60 * rem; sec.second = min.second; } else { diff --git a/test/data/issue_2320_poc.jpg b/test/data/issue_2320_poc.jpg new file mode 100644 index 00000000..5757e109 Binary files /dev/null and b/test/data/issue_2320_poc.jpg differ diff --git a/tests/bugfixes/github/test_issue_2320.py b/tests/bugfixes/github/test_issue_2320.py new file mode 100644 index 00000000..9aec7761 --- /dev/null +++ b/tests/bugfixes/github/test_issue_2320.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- + +from system_tests import CaseMeta, check_no_ASAN_UBSAN_errors + +class issue_2320_printDegrees_integer_overflow(metaclass=CaseMeta): + url = "https://github.com/Exiv2/exiv2/issues/2320" + filename = "$data_path/issue_2320_poc.jpg" + commands = ["$exiv2 -q -pa $filename"] + retval = [0] + stderr = [""] + compare_stdout = check_no_ASAN_UBSAN_errors diff --git a/tests/regression_tests/test_regression_allfiles.py b/tests/regression_tests/test_regression_allfiles.py index b969fc5a..015ecdbb 100644 --- a/tests/regression_tests/test_regression_allfiles.py +++ b/tests/regression_tests/test_regression_allfiles.py @@ -92,6 +92,7 @@ def get_valid_files(data_dir): "issue_2160_poc.jpg", "issue_2178_poc.jp2", "issue_2268_poc.jp2", + "issue_2320_poc.jpg", "issue_ghsa_583f_w9pm_99r2_poc.jp2", "issue_ghsa_7569_phvm_vwc2_poc.jp2", "issue_ghsa_mxw9_qx4c_6m8v_poc.jp2",