diff --git a/src/image.cpp b/src/image.cpp index 7857896fb6..2f7c44766c 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -383,8 +383,6 @@ void Image::printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStruct if (allocate64 > io.size()) { throw Error(ErrorCode::kerInvalidMalloc); } - // Overflow check - Internal::enforce(allocate64 <= std::numeric_limits::max(), ErrorCode::kerCorruptedMetadata); DataBuf buf(allocate64); // allocate a buffer std::copy_n(dir.c_data(8), 4, buf.begin()); // copy dir[8:11] into buffer (short strings) diff --git a/src/pngchunk_int.cpp b/src/pngchunk_int.cpp index 342cc7bf96..183d1b27e0 100644 --- a/src/pngchunk_int.cpp +++ b/src/pngchunk_int.cpp @@ -520,9 +520,6 @@ DataBuf PngChunk::readRawProfile(const DataBuf& text, bool iTXt) { while ('0' <= *sp && *sp <= '9') { // Compute the new length using unsigned long, so that we can check for overflow. const size_t newlength = (10 * length) + (*sp - '0'); - if (newlength > std::numeric_limits::max()) { - return {}; // Integer overflow. - } length = newlength; sp++; if (sp == eot) { diff --git a/src/preview.cpp b/src/preview.cpp index a7f9412326..e686df08c7 100644 --- a/src/preview.cpp +++ b/src/preview.cpp @@ -874,8 +874,6 @@ DataBuf decodeBase64(const std::string& src) { const unsigned long destSize = (validSrcSize * 3) / 4; // allocate dest buffer - if (destSize > LONG_MAX) - return {}; // avoid integer overflow DataBuf dest(destSize); // decode diff --git a/src/rafimage.cpp b/src/rafimage.cpp index 0994b8aad8..1180344ea3 100644 --- a/src/rafimage.cpp +++ b/src/rafimage.cpp @@ -245,11 +245,6 @@ void RafImage::readMetadata() { Internal::enforce(Safe::add(jpg_img_off_u32, jpg_img_len_u32) <= io_->size(), ErrorCode::kerCorruptedMetadata); -#if LONG_MAX < UINT_MAX - Internal::enforce(jpg_img_off_u32 <= std::numeric_limits::max(), ErrorCode::kerCorruptedMetadata); - Internal::enforce(jpg_img_len_u32 <= std::numeric_limits::max(), ErrorCode::kerCorruptedMetadata); -#endif - auto jpg_img_off = static_cast(jpg_img_off_u32); auto jpg_img_len = static_cast(jpg_img_len_u32); diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index 49faf99679..564338da64 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -1456,7 +1456,7 @@ static const TagInfo* findTagInfo(uint16_t tag, IfdId group) { const TagInfo* result = nullptr; const TagInfo* tags = [=] { if (group == IfdId::gpsId) - return group == IfdId::exifId ? Internal::exifTagList() : Internal::gpsTagList(); + return Internal::gpsTagList(); return group == IfdId::exifId ? Internal::exifTagList() : nullptr; }(); if (tags) { diff --git a/src/value.cpp b/src/value.cpp index 77ceae54b3..7c5b64f7ef 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -977,7 +977,7 @@ std::ostream& TimeValue::write(std::ostream& os) const { int64_t TimeValue::toInt64(size_t /*n*/) const { // Returns number of seconds in the day in UTC. auto result = static_cast(time_.hour - time_.tzHour) * 60 * 60; - result += (time_.minute - time_.tzMinute) * 60; + result += static_cast(time_.minute - time_.tzMinute) * 60; result += time_.second; if (result < 0) { result += 86400;