Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #6783 from EOSIO/org-limit-assert-1.6.x
Browse files Browse the repository at this point in the history
limit assert 1.6.x
  • Loading branch information
heifner authored Feb 19, 2019
2 parents 250e33f + fd77886 commit f97f0de
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions libraries/chain/wasm_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <fstream>
#include <string.h>

namespace eosio { namespace chain {
using namespace webassembly;
Expand Down Expand Up @@ -901,6 +902,8 @@ class system_api : public context_aware_api {

};

constexpr size_t max_assert_message = 1024;

class context_free_system_api : public context_aware_api {
public:
explicit context_free_system_api( apply_context& ctx )
Expand All @@ -913,14 +916,16 @@ class context_free_system_api : public context_aware_api {
// Kept as intrinsic rather than implementing on WASM side (using eosio_assert_message and strlen) because strlen is faster on native side.
void eosio_assert( bool condition, null_terminated_ptr msg ) {
if( BOOST_UNLIKELY( !condition ) ) {
std::string message( msg );
const size_t sz = strnlen( msg, max_assert_message );
std::string message( msg, sz );
EOS_THROW( eosio_assert_message_exception, "assertion failure with message: ${s}", ("s",message) );
}
}

void eosio_assert_message( bool condition, array_ptr<const char> msg, size_t msg_len ) {
if( BOOST_UNLIKELY( !condition ) ) {
std::string message( msg, msg_len );
const size_t sz = msg_len > max_assert_message ? max_assert_message : msg_len;
std::string message( msg, sz );
EOS_THROW( eosio_assert_message_exception, "assertion failure with message: ${s}", ("s",message) );
}
}
Expand Down

0 comments on commit f97f0de

Please sign in to comment.