Merge pull request #1210 from Exiv2/fix_547_0.27

Fix 547 0.27
This commit is contained in:
Robin Mills 2020-05-20 10:18:09 +01:00 committed by GitHub
commit f16c4c6b83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 4 deletions

View File

@ -53,7 +53,8 @@ install:
- 7z x ninja.zip -oC:\projects\deps\ninja > nul
- set PATH=C:\projects\deps\ninja;%PATH%
- ninja --version
- pip.exe install conan==1.24.1
- python -m pip install --upgrade pip
- pip3.exe install conan==1.24.1
- cd %APPVEYOR_BUILD_FOLDER%
before_build:

View File

@ -57,7 +57,15 @@ case "$distro_id" in
'opensuse'|'opensuse-tumbleweed')
zypper --non-interactive refresh
zypper --non-interactive install gcc-c++ clang cmake make ccache libexpat-devel zlib-devel libssh-devel libcurl-devel gtest which dos2unix libxml2-tools
zypper --non-interactive install gcc-c++ clang cmake make ccache libexpat-devel zlib-devel libssh-devel curl tar libcurl-devel git which dos2unix libxml2-tools
pushd /tmp
curl -LO https://github.com/google/googletest/archive/release-1.8.0.tar.gz
tar xzf release-1.8.0.tar.gz
mkdir -p googletest-release-1.8.0/build
pushd googletest-release-1.8.0/build
cmake .. ; make ; make install
popd
popd
;;
*)
echo "Sorry, no predefined dependencies for your distribution $distro_id exist yet"

View File

@ -17,6 +17,7 @@ if [[ "$(uname -s)" == 'Linux' ]]; then
else
export CMAKE_OPTIONS="$CMAKE_OPTIONS -DEXIV2_TEAM_USE_SANITIZERS=ON"
fi
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_CXX_FLAGS=-Wno-deprecated"
mkdir build
cd build

View File

@ -40,8 +40,8 @@ def matrix_build(shared_libs, ccs, build_types, cmake_bin, cmake_options,
)
os.mkdir(cwd)
cmake = "{cmake_bin} {!s} -DCMAKE_BUILD_TYPE={build_type} " \
"-DBUILD_SHARED_LIBS={lib_type} -DEXIV2_BUILD_UNIT_TESTS={tests} "\
cmake = "{cmake_bin} {!s} -DCMAKE_BUILD_TYPE={build_type} -DCMAKE_CXX_FLAGS=-Wno-deprecated " \
"-DBUILD_SHARED_LIBS={lib_type} -DEXIV2_BUILD_UNIT_TESTS={tests} -DCMAKE_CXX_STANDARD=98 "\
"../..".format(
cmake_options, cmake_bin=cmake_bin, build_type=build_type,
lib_type=lib_type, tests="ON" if tests else "OFF"

View File

@ -71,6 +71,7 @@
#include <cassert>
#include <iostream>
#include <limits>
#include <set>
#include <sys/types.h>
#include <sys/stat.h>
@ -332,9 +333,11 @@ namespace Exiv2 {
return type >= 1 && type <= 13 ;
}
static std::set<long> visits; // #547
void Image::printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStructureOption option,uint32_t start,bool bSwap,char c,int depth)
{
depth++;
if ( depth == 1 ) visits.clear();
bool bFirst = true ;
// buffer
@ -361,6 +364,11 @@ namespace Exiv2 {
// Read the dictionary
for ( int i = 0 ; i < dirLength ; i ++ ) {
if ( visits.find(io.tell()) != visits.end() ) { // #547
throw Error(kerCorruptedMetadata);
}
visits.insert(io.tell());
if ( bFirst && bPrint ) {
out << Internal::indent(depth)
<< " address | tag | "

BIN
test/data/issue_547.poc Normal file

Binary file not shown.

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from system_tests import CaseMeta, path
import unittest
@unittest.skip("Skipping test using option -pR (only for Debug mode)")
class test_issue_547(metaclass=CaseMeta):
"""
Regression test for the bug described in:
https://github.com/Exiv2/exiv2/pull/547
"""
url = "https://github.com/Exiv2/exiv2/issues/547"
filename = path("$data_path/issue_547.poc")
commands = ["$exiv2 -pR $filename"]
stdout = ["""STRUCTURE OF TIFF FILE (II): $filename
address | tag | type | count | offset | value
12 | 0x0001 Version | SSHORT | 0 | |
"""]
stderr = [
"""Exiv2 exception in print action for file $filename:
$kerCorruptedMetadata
"""
]
retval = [1]