Skip to content

Commit

Permalink
crwimage: Check offset and size against total size
Browse files Browse the repository at this point in the history
Corrupted or specially crafted CRW images might exceed the overall
buffersize.

Fixes Exiv2#1019
  • Loading branch information
phako authored and 1div0 committed Jun 7, 2020
1 parent 8bd17c6 commit af86dba
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/crwimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ namespace Exiv2 {
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Reading directory 0x" << std::hex << tag() << "\n";
#endif
if (this->offset() + this->size() > size)
throw Error(kerOffsetOutOfRange);

readDirectory(pData + offset(), this->size(), byteOrder);
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "<---- 0x" << std::hex << tag() << "\n";
Expand Down

0 comments on commit af86dba

Please sign in to comment.