Skip to content

Commit

Permalink
Fix buffer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
eisenhauer committed Jan 27, 2025
1 parent f80ad82 commit 45655d4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source/adios2/toolkit/format/bp5/BP5Helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ BP5Helper::BuildNodeContrib(const digest attrHash, const size_t attrSize,
sizeof(uint64_t);
ret.resize(len);
size_t position = 0;
helper::CopyToBuffer(ret, position, &attrHash.x[0], sizeof(digest));
helper::CopyToBuffer(ret, position, (char *)&attrHash.x[0], sizeof(digest));
helper::CopyToBuffer(ret, position, &attrSize, 1);
helper::CopyToBuffer(ret, position, &MMBlocksSize, 1);
for (auto &MM : MMBlocks)
{
digest D;
std::memcpy(&D.x[0], MM.MetaMetaID, MM.MetaMetaIDLen);
helper::CopyToBuffer(ret, position, &D.x[0], sizeof(digest));
helper::CopyToBuffer(ret, position, (char *)&D.x[0], sizeof(digest));
size_t AlignedSize = ((MM.MetaMetaInfoLen + 7) & ~0x7);
helper::CopyToBuffer(ret, position, &AlignedSize, 1);
}
Expand Down Expand Up @@ -196,7 +196,7 @@ void BP5Helper::BreakdownIncomingMInfo(
bool needAttr = false;
size_t MMBlockCount;
size_t SecondRecvSize = 0;
helper::ReadArray(RecvBuffer, pos, &thisAttrHash.x[0], sizeof(thisAttrHash.x), false);
helper::ReadArray(RecvBuffer, pos, (char *)&thisAttrHash.x[0], sizeof(thisAttrHash.x), false);
size_t AttrSize = helper::ReadValue<size_t>(RecvBuffer, pos, false);
AttrSizes[node] = AttrSize;
if (AttrSize && !AttrSet.count(thisAttrHash))
Expand All @@ -212,7 +212,7 @@ void BP5Helper::BreakdownIncomingMInfo(
for (size_t block = 0; block < MMBlockCount; block++)
{
digest thisMMB;
helper::ReadArray(RecvBuffer, pos, &thisMMB.x[0], sizeof(thisMMB.x), false);
helper::ReadArray(RecvBuffer, pos, (char *)&thisMMB.x[0], sizeof(thisMMB.x), false);
size_t thisMMBSize = helper::ReadValue<size_t>(RecvBuffer, pos, false);
if (thisMMBSize && (!MMBSet.count(thisMMB)))
{
Expand Down

0 comments on commit 45655d4

Please sign in to comment.