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 #6883 from EOSIO/1.7.0-rc2-dev-security-omnibus
Browse files Browse the repository at this point in the history
Consolidated Security Fixes for 1.7.0-rc2
  • Loading branch information
heifner authored Mar 6, 2019
2 parents 6530bed + 4811496 commit 1312541
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 1 addition & 3 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1033,9 +1033,7 @@ struct controller_impl {
recovered_keys,
{},
trx_context.delay,
[](){}
/*std::bind(&transaction_context::add_cpu_usage_and_check_time, &trx_context,
std::placeholders::_1)*/,
[&trx_context](){ trx_context.checktime(); },
false
);
}
Expand Down
17 changes: 16 additions & 1 deletion plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ namespace eosio {
void rejected_block(const block_id_type& id);

void recv_block(const connection_ptr& conn, const block_id_type& msg, uint32_t bnum);
void expire_blocks( uint32_t bnum );
void recv_transaction(const connection_ptr& conn, const transaction_id_type& id);
void recv_notice(const connection_ptr& conn, const notice_message& msg, bool generated);

Expand Down Expand Up @@ -1656,11 +1657,23 @@ namespace eosio {
}

void dispatch_manager::rejected_block(const block_id_type& id) {
fc_dlog(logger,"not sending rejected transaction ${tid}",("tid",id));
fc_dlog( logger, "rejected block ${id}", ("id", id) );
auto range = received_blocks.equal_range(id);
received_blocks.erase(range.first, range.second);
}

void dispatch_manager::expire_blocks( uint32_t lib_num ) {
for( auto i = received_blocks.begin(); i != received_blocks.end(); ) {
const block_id_type& blk_id = i->first;
uint32_t blk_num = block_header::num_from_id( blk_id );
if( blk_num <= lib_num ) {
i = received_blocks.erase( i );
} else {
++i;
}
}
}

void dispatch_manager::bcast_transaction(const transaction_metadata_ptr& ptrx) {
std::set<connection_ptr> skips;
const auto& id = ptrx->id;
Expand Down Expand Up @@ -2590,6 +2603,7 @@ namespace eosio {
}
else {
sync_master->rejected_block(c, blk_num);
dispatcher->rejected_block( blk_id );
}
}

Expand Down Expand Up @@ -2657,6 +2671,7 @@ namespace eosio {

controller& cc = chain_plug->chain();
uint32_t lib = cc.last_irreversible_block_num();
dispatcher->expire_blocks( lib );
for ( auto &c : connections ) {
auto &stale_txn = c->trx_state.get<by_block_num>();
stale_txn.erase( stale_txn.lower_bound(1), stale_txn.upper_bound(lib) );
Expand Down

0 comments on commit 1312541

Please sign in to comment.