Skip to content

Commit

Permalink
Merge pull request #642 from AntelopeIO/multi3-uint128
Browse files Browse the repository at this point in the history
swtich `__multi3` to `unsigned __int128` to avoid integer overflow UB
  • Loading branch information
spoonincode authored Sep 9, 2024
2 parents 3ba08b0 + 14af02d commit f931c0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1928,7 +1928,7 @@ namespace webassembly {
void __lshrti3(legacy_ptr<int128_t>, uint64_t, uint64_t, uint32_t) const;
void __divti3(legacy_ptr<int128_t>, uint64_t, uint64_t, uint64_t, uint64_t) const;
void __udivti3(legacy_ptr<uint128_t>, uint64_t, uint64_t, uint64_t, uint64_t) const;
void __multi3(legacy_ptr<int128_t>, uint64_t, uint64_t, uint64_t, uint64_t) const;
void __multi3(legacy_ptr<uint128_t>, uint64_t, uint64_t, uint64_t, uint64_t) const;
void __modti3(legacy_ptr<int128_t>, uint64_t, uint64_t, uint64_t, uint64_t) const;
void __umodti3(legacy_ptr<uint128_t>, uint64_t, uint64_t, uint64_t, uint64_t) const;
void __addtf3(legacy_ptr<float128_t>, uint64_t, uint64_t, uint64_t, uint64_t) const;
Expand Down
6 changes: 3 additions & 3 deletions libraries/chain/webassembly/compiler_builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ namespace eosio { namespace chain { namespace webassembly {
*ret = lhs;
}

void interface::__multi3(legacy_ptr<__int128> ret, uint64_t la, uint64_t ha, uint64_t lb, uint64_t hb) const {
__int128 lhs = ha;
__int128 rhs = hb;
void interface::__multi3(legacy_ptr<uint128_t> ret, uint64_t la, uint64_t ha, uint64_t lb, uint64_t hb) const {
uint128_t lhs = ha;
uint128_t rhs = hb;

lhs <<= 64;
lhs |= la;
Expand Down

0 comments on commit f931c0f

Please sign in to comment.