Skip to content

Commit

Permalink
libertiff.hpp: avoid harmless unsigned integer overflow (oss-fuzz #38…
Browse files Browse the repository at this point in the history
…9332105)
  • Loading branch information
rouault committed Jan 11, 2025
1 parent ea26bd0 commit 926f93b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions third_party/libertiff/libertiff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,12 @@ class Image
uint64_t offset = imageOffset;
if LIBERTIFF_CONSTEXPR (isBigTIFF)
{
// To prevent unsigned integer overflows in later additions. The
// theoretical max should be much closer to UINT64_MAX, but half of
// it is already more than needed in practice :-)
if (offset >= std::numeric_limits<uint64_t>::max() / 2)
return nullptr;

const auto tagCount64Bit = rc->read<uint64_t>(offset, ok);
// Artificially limit to the same number of entries as ClassicTIFF
if (tagCount64Bit > std::numeric_limits<uint16_t>::max())
Expand Down

0 comments on commit 926f93b

Please sign in to comment.