Skip to content

Commit ded6bc6

Browse files
kevinbackhousekmilos
authored andcommitted
Check for integer overflow.
1 parent 9e3f394 commit ded6bc6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/psdimage.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ void PsdImage::readResourceBlock(uint16_t resourceId, uint32_t resourceSize) {
287287
nativePreview.height_ = getLong(buf + 8, bigEndian);
288288
const uint32_t format = getLong(buf + 0, bigEndian);
289289

290+
Internal::enforce(nativePreview.size_ <= static_cast<size_t>(std::numeric_limits<long>::max()),
291+
Exiv2::ErrorCode::kerCorruptedMetadata);
292+
290293
if (nativePreview.size_ > 0 && nativePreview.position_ > 0) {
291294
io_->seek(static_cast<long>(nativePreview.size_), BasicIo::cur);
292295
if (io_->error() || io_->eof())

0 commit comments

Comments
 (0)