diff options
author | luigi1111 <luigi1111w@gmail.com> | 2020-07-31 15:05:03 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2020-07-31 15:05:03 -0500 |
commit | 7f8fe816f47b9fc7c4ba11c70363211de62073e1 (patch) | |
tree | ce3736dcc903a154fdfc821ba0a04ed30e761da7 /src | |
parent | Merge pull request #6672 (diff) | |
parent | rpc: reject wrong sized txid (diff) | |
download | monero-7f8fe816f47b9fc7c4ba11c70363211de62073e1.tar.xz |
Merge pull request #6728
870a7b5 rpc: reject wrong sized txid (moneromooo-monero)
5b761d0 easylogging++: fix crash with reentrant logging (moneromooo-monero)
c02d762 epee: guard against exceptions in RPC handlers (moneromooo-monero)
0678fc1 blockchain: guard against exceptions in add_new_block/children (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 11 | ||||
-rw-r--r-- | src/rpc/core_rpc_server.cpp | 10 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index ef3962afd..f135fb9aa 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -4253,6 +4253,9 @@ bool Blockchain::update_next_cumulative_weight_limit(uint64_t *long_term_effecti //------------------------------------------------------------------ bool Blockchain::add_new_block(const block& bl, block_verification_context& bvc) { + try + { + LOG_PRINT_L3("Blockchain::" << __func__); crypto::hash id = get_block_hash(bl); CRITICAL_REGION_LOCAL(m_tx_pool);//to avoid deadlock lets lock tx_pool for whole add/reorganize process @@ -4280,6 +4283,14 @@ bool Blockchain::add_new_block(const block& bl, block_verification_context& bvc) rtxn_guard.stop(); return handle_block_to_main_chain(bl, id, bvc); + + } + catch (const std::exception &e) + { + LOG_ERROR("Exception at [add_new_block], what=" << e.what()); + bvc.m_verifivation_failed = true; + return false; + } } //------------------------------------------------------------------ //TODO: Refactor, consider returning a failure height and letting diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 3807d73d9..30b6190ab 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -2453,14 +2453,13 @@ namespace cryptonote { for (const auto &str: req.txids) { - cryptonote::blobdata txid_data; - if(!epee::string_tools::parse_hexstr_to_binbuff(str, txid_data)) + crypto::hash txid; + if(!epee::string_tools::hex_to_pod(str, txid)) { failed = true; } else { - crypto::hash txid = *reinterpret_cast<const crypto::hash*>(txid_data.data()); txids.push_back(txid); } } @@ -2805,15 +2804,14 @@ namespace cryptonote res.status = ""; for (const auto &str: req.txids) { - cryptonote::blobdata txid_data; - if(!epee::string_tools::parse_hexstr_to_binbuff(str, txid_data)) + crypto::hash txid; + if(!epee::string_tools::hex_to_pod(str, txid)) { if (!res.status.empty()) res.status += ", "; res.status += std::string("invalid transaction id: ") + str; failed = true; continue; } - crypto::hash txid = *reinterpret_cast<const crypto::hash*>(txid_data.data()); cryptonote::blobdata txblob; if (m_core.get_pool_transaction(txid, txblob, relay_category::legacy)) |