Skip to content

Commit

Permalink
Assembly: Fix check for the maximum size of the EOF data section
Browse files Browse the repository at this point in the history
  • Loading branch information
cameel committed Dec 19, 2024
1 parent 715573a commit bb9d694
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libevmasm/Assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,8 +1683,12 @@ LinkerObject const& Assembly::assembleEOF() const
// DATALOADN loads 32 bytes from EOF data section zero padded if reading out of data bounds.
// In our case we do not allow DATALOADN with offsets which reads out of data bounds.
auto const staticAuxDataSize = maxAuxDataLoadNOffset.has_value() ? (*maxAuxDataLoadNOffset + 32u) : 0u;
solRequire(preDeployDataSectionSize + staticAuxDataSize < std::numeric_limits<uint16_t>::max(), AssemblyException,
"Invalid DATALOADN offset.");
auto const preDeployAndStaticAuxDataSize = preDeployDataSectionSize + staticAuxDataSize;
solRequire(
preDeployAndStaticAuxDataSize <= std::numeric_limits<uint16_t>::max(),
AssemblyException,
"Invalid DATALOADN offset."
);

// If some data was already added to data section we need to update data section refs accordingly
if (preDeployDataSectionSize > 0)
Expand All @@ -1695,8 +1699,6 @@ LinkerObject const& Assembly::assembleEOF() const
setBigEndianUint16(ret.bytecode, refPosition, staticAuxDataOffset + preDeployDataSectionSize);
}

auto const preDeployAndStaticAuxDataSize = preDeployDataSectionSize + staticAuxDataSize;

setBigEndianUint16(ret.bytecode, dataSectionSizePosition, preDeployAndStaticAuxDataSize);

return ret;
Expand Down

0 comments on commit bb9d694

Please sign in to comment.