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

Automatic backport of pull request #706 #717

Merged
merged 2 commits into from
Feb 28, 2019
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
12 changes: 5 additions & 7 deletions src/tiffimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1671,10 +1671,10 @@ namespace Exiv2 {

} // TiffParserWorker::parse

void TiffParserWorker::findPrimaryGroups(PrimaryGroups& primaryGroups,
TiffComponent* pSourceDir)
void TiffParserWorker::findPrimaryGroups(PrimaryGroups& primaryGroups, TiffComponent* pSourceDir)
{
if (0 == pSourceDir) return;
if (0 == pSourceDir)
return;

const IfdId imageGroups[] = {
ifd0Id,
Expand All @@ -1696,10 +1696,8 @@ namespace Exiv2 {
TiffFinder finder(0x00fe, imageGroups[i]);
pSourceDir->accept(finder);
TiffEntryBase* te = dynamic_cast<TiffEntryBase*>(finder.result());
if ( te
&& te->pValue()->typeId() == unsignedLong
&& te->pValue()->count() == 1
&& (te->pValue()->toLong() & 1) == 0) {
const Value* pV = te != nullptr ? te->pValue() : nullptr;
if (pV && pV->typeId() == unsignedLong && pV->count() == 1 && (pV->toLong() & 1) == 0) {
primaryGroups.push_back(te->group());
}
}
Expand Down
Binary file added test/data/tiffimage_int-out-of-bound-read-poc-2
Binary file not shown.
24 changes: 24 additions & 0 deletions tests/bugfixes/github/test_issue_590.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-

import system_tests


URL = "https://github.com/Exiv2/exiv2/issues/590"


@system_tests.CopyFiles("$data_path/tiffimage_int-out-of-bound-read-poc-2")
class TiffImageIntOutOfBoundsRead(metaclass=system_tests.CaseMeta):
"""
Regression test for the second issue reported in #590.
"""

filename = system_tests.path(
"$data_path/tiffimage_int-out-of-bound-read-poc-2_copy"
)

compare_stderr = system_tests.check_no_ASAN_UBSAN_errors

commands = ["$exiv2 -Y 2011 -O 02 -D 29 adjust $filename"]
stdout = [""]
stderr = [""]
retval = [0]