diff --git a/appveyor.yml b/appveyor.yml index 461d7bf5b2..68ce0000f1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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: diff --git a/ci/install_dependencies.sh b/ci/install_dependencies.sh index 969cd396d5..396319d92d 100755 --- a/ci/install_dependencies.sh +++ b/ci/install_dependencies.sh @@ -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" diff --git a/ci/run.sh b/ci/run.sh index 2a6dfe4011..5257480272 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -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 diff --git a/ci/test_build.py b/ci/test_build.py index 84e68c52a3..462409bded 100644 --- a/ci/test_build.py +++ b/ci/test_build.py @@ -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" diff --git a/src/image.cpp b/src/image.cpp index 2e356fbbb3..2fa41e5b57 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -71,6 +71,7 @@ #include #include #include +#include #include #include @@ -332,9 +333,11 @@ namespace Exiv2 { return type >= 1 && type <= 13 ; } + static std::set 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 | " diff --git a/test/data/issue_547.poc b/test/data/issue_547.poc new file mode 100644 index 0000000000..1427e8eeda Binary files /dev/null and b/test/data/issue_547.poc differ diff --git a/tests/bugfixes/github/test_issue_547.py b/tests/bugfixes/github/test_issue_547.py new file mode 100644 index 0000000000..f81fdb16c2 --- /dev/null +++ b/tests/bugfixes/github/test_issue_547.py @@ -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]