Skip to content

Commit

Permalink
Merge pull request #1852 from Exiv2/mergify/bp/main/pr-1846
Browse files Browse the repository at this point in the history
Replace assertion with error message in TiffDirectory::writeDirEntry() (backport #1846)
  • Loading branch information
kevinbackhouse authored Aug 6, 2021
2 parents 330483a + 9fd8b40 commit 0dc5cdd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/tiffcomposite_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,12 @@ namespace Exiv2 {
valueIdx,
dataIdx,
imageIdx);
assert(len <= 4);
#ifndef SUPPRESS_WARNINGS
if (len > 4) {
EXV_ERROR << "Unexpected length in TiffDirectory::writeDirEntry(): len == "
<< len << ".\n";
}
#endif
if (len < 4) {
memset(buf, 0x0, 4);
ioWrapper.write(buf, 4 - len);
Expand Down
Binary file added test/data/issue_1845_poc.jp2
Binary file not shown.
17 changes: 17 additions & 0 deletions tests/bugfixes/github/test_issue_1845.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-

from system_tests import CaseMeta, CopyTmpFiles, path
@CopyTmpFiles("$data_path/issue_1845_poc.jp2")

class TiffDirectoryWriteDirEntryAssert(metaclass=CaseMeta):
"""
Regression test for the bug described in:
https://github.com/Exiv2/exiv2/issues/1845
"""
url = "https://github.com/Exiv2/exiv2/issues/1845"

filename = path("$tmp_path/issue_1845_poc.jp2")
commands = ["$exiv2 -q -D +1 ad $filename"]
stderr = [""]
stdout = [""]
retval = [0]

0 comments on commit 0dc5cdd

Please sign in to comment.