Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/runtime_src/tools/xclbinutil/SectionBMC.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,9 @@ SectionBMC::copyBufferUpdateMetadata(const char* _pOrigDataSection,
% pHdr->m_version
% pHdr->m_md5value);

uint64_t expectedSize = pHdr->m_offset + pHdr->m_size;

// Check to see if array size
if (expectedSize > _origSectionSize) {
auto errMsg = boost::format("ERROR: bmc section size (0x%lx) exceeds the given segment size (0x%lx).") % expectedSize % _origSectionSize;
// Guard against uint64_t overflow before comparing against section size
if (pHdr->m_size > _origSectionSize || pHdr->m_offset > _origSectionSize - pHdr->m_size) {
auto errMsg = boost::format("ERROR: bmc m_offset (0x%lx) + m_size (0x%lx) exceeds the given segment size (0x%lx).") % pHdr->m_offset % pHdr->m_size % _origSectionSize;
throw std::runtime_error(errMsg.str());
}

Expand Down
Loading