Skip to content

Commit

Permalink
Merge pull request EOSIO#3707 from EOSIO/wasm_memcmp_sanitize
Browse files Browse the repository at this point in the history
Sanitize the return value of memcmp() to wasm
  • Loading branch information
b1bart authored Jun 1, 2018
2 parents 710a34d + 9115d36 commit cf6b059
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libraries/chain/wasm_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,12 @@ class memory_api : public context_aware_api {
}

int memcmp( array_ptr<const char> dest, array_ptr<const char> src, size_t length) {
return ::memcmp(dest, src, length);
int ret = ::memcmp(dest, src, length);
if(ret < 0)
return -1;
if(ret > 0)
return 1;
return 0;
}

char* memset( array_ptr<char> dest, int value, size_t length ) {
Expand Down

0 comments on commit cf6b059

Please sign in to comment.