diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index ba24287246..0b34a56d4d 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -1025,9 +1025,16 @@ namespace Exiv2 { if (!mn_) { return TiffEntryBase::doCount(); } +#ifndef SUPPRESS_WARNINGS // Count of IFD makernote in tag Exif.Photo.MakerNote is the size of the // Makernote in bytes - assert(tiffType() == ttUndefined || tiffType() == ttUnsignedByte || tiffType() == ttSignedByte); + if (tiffType() != ttUndefined && tiffType() != ttUnsignedByte && tiffType() != ttSignedByte) { + EXV_ERROR << "Makernote entry 0x" << std::setw(4) + << std::setfill('0') << std::hex << tag() + << " has incorrect Exif (TIFF) type " << std::dec << tiffType() + << ". (Expected signed or unsigned byte.)\n"; + } +#endif return mn_->size(); } diff --git a/test/data/issue_1833_poc.jpg b/test/data/issue_1833_poc.jpg new file mode 100644 index 0000000000..c9800ceeef Binary files /dev/null and b/test/data/issue_1833_poc.jpg differ diff --git a/tests/bugfixes/github/test_issue_1833.py b/tests/bugfixes/github/test_issue_1833.py new file mode 100644 index 0000000000..5508e08f0e --- /dev/null +++ b/tests/bugfixes/github/test_issue_1833.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +from system_tests import CaseMeta, path, check_no_ASAN_UBSAN_errors + +class TiffMnEntryDoCountInvalidTiffType(metaclass=CaseMeta): + """ + Test for the bug described in: + https://github.com/Exiv2/exiv2/issues/1833 + """ + url = "https://github.com/Exiv2/exiv2/issues/1833" + + filename = path("$data_path/issue_1833_poc.jpg") + commands = ["$exiv2 -pS $filename"] + stderr = [""] + retval = [0] + + compare_stdout = check_no_ASAN_UBSAN_errors