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 error message in TiffDirectory::writeDirEntry() (backport #1846) #1852

Merged
merged 2 commits into from
Aug 6, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]