Skip to content

Commit 8ffed02

Browse files
Check for integer overflow.
1 parent 7adedce commit 8ffed02

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/psdimage.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ void PsdImage::readResourceBlock(uint16_t resourceId, uint32_t resourceSize) {
284284
nativePreview.height_ = getLong(buf + 8, bigEndian);
285285
const uint32_t format = getLong(buf + 0, bigEndian);
286286

287+
Internal::enforce(nativePreview.size_ <= static_cast<size_t>(std::numeric_limits<long>::max()),
288+
Exiv2::ErrorCode::kerCorruptedMetadata);
289+
287290
if (nativePreview.size_ > 0 && nativePreview.position_ > 0) {
288291
io_->seek(static_cast<long>(nativePreview.size_), BasicIo::cur);
289292
if (io_->error() || io_->eof())
@@ -524,7 +527,7 @@ void PsdImage::doWriteMetadata(BasicIo& outIo) {
524527
if (outIo.error())
525528
throw Error(ErrorCode::kerImageWriteFailed);
526529

527-
// Update length of resources
530+
// Update length of resources
528531
#ifdef EXIV2_DEBUG_MESSAGES
529532
std::cerr << "newResLength: " << newResLength << "\n";
530533
#endif

0 commit comments

Comments
 (0)