Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace assertion with an error message #1834

Merged
merged 1 commit into from Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/tiffcomposite_int.cpp
Expand Up @@ -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();
}

Expand Down
Binary file added test/data/issue_1833_poc.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions 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