From 8ff26931e31bb25d66c69846f47f3f5b6d9a32f1 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Mon, 22 Jan 2018 23:26:17 +0100 Subject: [PATCH] Do not use Image::printStructure() when reading images as this causes security issues. --- src/cr2image.cpp | 2 -- src/crwimage.cpp | 11 ++--------- src/orfimage.cpp | 2 -- src/rw2image.cpp | 2 -- src/tiffimage.cpp | 4 ---- 5 files changed, 2 insertions(+), 19 deletions(-) diff --git a/src/cr2image.cpp b/src/cr2image.cpp index d9f6b149..fcfff75b 100644 --- a/src/cr2image.cpp +++ b/src/cr2image.cpp @@ -102,8 +102,6 @@ namespace Exiv2 { throw Error(kerNotAnImage, "CR2"); } clearMetadata(); - std::ofstream devnull; - printStructure(devnull, kpsRecursive, 0); ByteOrder bo = Cr2Parser::decode(exifData_, iptcData_, xmpData_, diff --git a/src/crwimage.cpp b/src/crwimage.cpp index b7871468..d1124992 100644 --- a/src/crwimage.cpp +++ b/src/crwimage.cpp @@ -101,15 +101,8 @@ namespace Exiv2 { throw Error(kerNotACrwImage); } clearMetadata(); - // read all metadata into memory - // we should put this into clearMetadata(), however it breaks the test suite! - try { - std::ofstream devnull; - printStructure(devnull,kpsRecursive,0); - } catch (Exiv2::Error& /* e */) { - DataBuf file( (long) io().size()); - io_->read(file.pData_,file.size_); - } + DataBuf file( (long) io().size()); + io_->read(file.pData_,file.size_); CrwParser::decode(this, io_->mmap(), (uint32_t) io_->size()); diff --git a/src/orfimage.cpp b/src/orfimage.cpp index 3177e360..8a36a6bb 100644 --- a/src/orfimage.cpp +++ b/src/orfimage.cpp @@ -114,8 +114,6 @@ namespace Exiv2 { throw Error(kerNotAnImage, "ORF"); } clearMetadata(); - std::ofstream devnull; - printStructure(devnull, kpsRecursive, 0); ByteOrder bo = OrfParser::decode(exifData_, iptcData_, xmpData_, diff --git a/src/rw2image.cpp b/src/rw2image.cpp index ae489682..faf51261 100644 --- a/src/rw2image.cpp +++ b/src/rw2image.cpp @@ -125,8 +125,6 @@ namespace Exiv2 { throw Error(kerNotAnImage, "RW2"); } clearMetadata(); - std::ofstream devnull; - printStructure(devnull, kpsRecursive, 0); ByteOrder bo = Rw2Parser::decode(exifData_, iptcData_, xmpData_, diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp index 529ba4a3..8731449c 100644 --- a/src/tiffimage.cpp +++ b/src/tiffimage.cpp @@ -180,10 +180,6 @@ namespace Exiv2 { } clearMetadata(); - // recursively print the structure to /dev/null to ensure all metadata is in memory - // must be recursive to handle NEFs which stores the raw image in a subIFDs - std::ofstream devnull; - printStructure(devnull,kpsRecursive); ByteOrder bo = TiffParser::decode(exifData_, iptcData_, xmpData_,