From 37b8ee22c8f205cec922ad40d3fb0c15652f0a4a Mon Sep 17 00:00:00 2001 From: yarkin Date: Mon, 14 Aug 2023 23:02:34 +0800 Subject: [PATCH] Fix an unsafe intx::load. --- src/actions.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/actions.cpp b/src/actions.cpp index 11ee59d6..116bf5c9 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -611,9 +611,9 @@ void evm_contract::admincall(const bytes& from, const bytes& to, const bytes& va // Prepare s eosio::check(from.size() == kAddressLength, err_msg_invalid_addr); - intx::uint256 s = intx::be::unsafe::load((const uint8_t *)from.data()); - // load will put the data in higher bytes, shift them donw. - s >>= 256 - kAddressLength * 8; + uint8_t s_buffer[32] = {}; + memcpy(s_buffer + 32 - kAddressLength, from.data(), kAddressLength); + intx::uint256 s = intx::be::load(s_buffer); // pad with '1's s |= ((~intx::uint256(0)) << (kAddressLength * 8));