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

Fix assertion failure in crwimage_int.cpp (backport #1739) #1779

Merged
merged 4 commits into from
Jul 15, 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
10 changes: 7 additions & 3 deletions src/crwimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1228,13 +1228,17 @@ namespace Exiv2 {
std::memset(buf.pData_, 0x0, buf.size_);

uint16_t len = 0;

for (auto&& exif : exifData) {
if (exif.ifdId() != ifdId)
continue;
const uint16_t s = exif.tag() * 2 + static_cast<uint16_t>(exif.size());
assert(s <= size);
if (len < s) len = s;
exif.copy(buf.pData_ + exif.tag() * 2, byteOrder);
if (s <= size) {
if (len < s) len = s;
exif.copy(buf.pData_ + exif.tag() * 2, byteOrder);
} else {
EXV_ERROR << "packIfdId out-of-bounds error: s = " << std::dec << s << "\n";
}
}
// Round the size to make it even.
buf.size_ = len + len%2;
Expand Down
Binary file added test/data/test_issue_ghsa_mv9g_fxh2_m49m.crw
Binary file not shown.
13 changes: 13 additions & 0 deletions tests/bugfixes/github/test_issue_ghsa_mv9g_fxh2_m49m.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-

from system_tests import CaseMeta, path

class test_issue_ghsa_mv9g_fxh2_m49m(metaclass=CaseMeta):

filename = path("$data_path/test_issue_ghsa_mv9g_fxh2_m49m.crw")
commands = ["$exiv2 -q fi $filename"]
stdout = [""]
stderr = ["""Exiv2 exception in fixiso action for file $filename:
$kerCorruptedMetadata
"""]
retval = [1]