exiv2/CVE-2018-17282.patch
2019-09-30 10:38:30 -04:00

41 lines
1.4 KiB
Diff

--- a/src/tiffimage.cpp
+++ b/src/tiffimage.cpp
@@ -171,11 +171,15 @@
#ifdef DEBUG
std::cerr << "Reading TIFF file " << io_->path() << "\n";
#endif
- if (io_->open() != 0) throw Error(9, io_->path(), strError());
+ if (io_->open() != 0) {
+ throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ }
+
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isTiffType(*io_, false)) {
- if (io_->error() || io_->eof()) throw Error(14);
+ if (io_->error() || io_->eof())
+ throw Error(kerFailedToReadImageData);
throw Error(3, "TIFF");
}
clearMetadata();
@@ -190,12 +194,16 @@
// read profile from the metadata
Exiv2::ExifKey key("Exif.Image.InterColorProfile");
Exiv2::ExifData::iterator pos = exifData_.findKey(key);
- if ( pos != exifData_.end() ) {
- iccProfile_.alloc(pos->count()*pos->typeSize());
+ if ( pos != exifData_.end() ) {
+ long size = pos->count() * pos->typeSize();
+ if (size == 0) {
+ throw Error(kerFailedToReadImageData);
+ }
+ iccProfile_.alloc(size);
pos->copy(iccProfile_.pData_,bo);
}
- } // TiffImage::readMetadata
+ }
void TiffImage::writeMetadata()
{