Skip to content

Commit

Permalink
Merge pull request Exiv2#1834 from kevinbackhouse/FixIssue1833
Browse files Browse the repository at this point in the history
Replace assertion with an error message
  • Loading branch information
kevinbackhouse authored Aug 3, 2021
2 parents ca32016 + 4ec1768 commit 9ccd5cb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/tiffcomposite_int.cpp
Original file line number Diff line number Diff line change
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
Loading
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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9ccd5cb

Please sign in to comment.