From 3c849188abcefff9c71c3c569353a965c4e466f2 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 26 Oct 2019 08:05:43 +0000 Subject: [PATCH 1/6] rpc: always set the update field in update on sucess Coverity 205416 --- src/rpc/core_rpc_server.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 9117b5b3a..dbacd489d 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -2617,6 +2617,7 @@ namespace cryptonote { RPC_TRACKER(update); + res.update = false; if (m_core.offline()) { res.status = "Daemon is running offline"; From d56a483abea2e7803ef47cbcb48a86a45e605410 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 26 Oct 2019 08:12:49 +0000 Subject: [PATCH 2/6] rpc: do not propagate exceptions out of a dtor Coverity 205415 --- src/rpc/core_rpc_server.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index dbacd489d..858b35df2 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -86,10 +86,14 @@ namespace RPCTracker(const char *rpc, tools::LoggingPerformanceTimer &timer): rpc(rpc), timer(timer) { } ~RPCTracker() { - boost::unique_lock lock(mutex); - auto &e = tracker[rpc]; - ++e.count; - e.time += timer.value(); + try + { + boost::unique_lock lock(mutex); + auto &e = tracker[rpc]; + ++e.count; + e.time += timer.value(); + } + catch (...) { /* ignore */ } } void pay(uint64_t amount) { boost::unique_lock lock(mutex); From d0faae2a922effe64706aae95a095d39c9c3e3ee Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 26 Oct 2019 08:16:08 +0000 Subject: [PATCH 3/6] rpc: init a few missing client_info members Coverity 205414 --- src/rpc/rpc_payment.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rpc/rpc_payment.cpp b/src/rpc/rpc_payment.cpp index 0637db728..b363c27b2 100644 --- a/src/rpc/rpc_payment.cpp +++ b/src/rpc/rpc_payment.cpp @@ -59,6 +59,10 @@ namespace cryptonote { rpc_payment::client_info::client_info(): + previous_seed_height(0), + seed_height(0), + previous_seed_hash(crypto::null_hash), + seed_hash(crypto::null_hash), cookie(0), top(crypto::null_hash), previous_top(crypto::null_hash), From 054b2621b1c8621afc3682b358bd02301d3aa2ea Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 26 Oct 2019 08:19:04 +0000 Subject: [PATCH 4/6] node_rpc_proxy: init some new rpc payment fields in invalidate The cache time would take care of these, but it's cleaner that way Coverity 205412 --- src/wallet/node_rpc_proxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wallet/node_rpc_proxy.cpp b/src/wallet/node_rpc_proxy.cpp index 005b0bafa..f3698b599 100644 --- a/src/wallet/node_rpc_proxy.cpp +++ b/src/wallet/node_rpc_proxy.cpp @@ -78,6 +78,10 @@ void NodeRPCProxy::invalidate() m_rpc_payment_seed_hash = crypto::null_hash; m_rpc_payment_next_seed_hash = crypto::null_hash; m_height_time = 0; + m_rpc_payment_diff = 0; + m_rpc_payment_credits_per_hash_found = 0; + m_rpc_payment_height = 0; + m_rpc_payment_cookie = 0; } boost::optional NodeRPCProxy::get_rpc_version(uint32_t &rpc_version) From fa16df9996700306d0976180156c320b8d529faf Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 26 Oct 2019 08:23:02 +0000 Subject: [PATCH 5/6] make_test_signature: exit nicely on top level exception Coverity 205411 --- tests/functional_tests/make_test_signature.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/functional_tests/make_test_signature.cc b/tests/functional_tests/make_test_signature.cc index 8c0333233..789523de5 100644 --- a/tests/functional_tests/make_test_signature.cc +++ b/tests/functional_tests/make_test_signature.cc @@ -32,6 +32,7 @@ int main(int argc, const char **argv) { + TRY_ENTRY(); if (argc > 2) { fprintf(stderr, "usage: %s \n", argv[0]); @@ -57,4 +58,5 @@ int main(int argc, const char **argv) std::string signature = cryptonote::make_rpc_payment_signature(skey); printf("%s\n", signature.c_str()); return 0; + CATCH_ENTRY_L0("main()", 1); } From b90c4bc39ee336bf0a0cb6e40876926baf06d1fe Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 26 Oct 2019 08:24:50 +0000 Subject: [PATCH 6/6] rpc: error out from get_info if the proxied call errors out Coverity 205410 --- src/rpc/core_rpc_server.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 858b35df2..5a4ad0506 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -2226,8 +2226,7 @@ namespace cryptonote //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_get_info_json(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx) { - on_get_info(req, res, ctx); - if (res.status != CORE_RPC_STATUS_OK) + if (!on_get_info(req, res, ctx) || res.status != CORE_RPC_STATUS_OK) { error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR; error_resp.message = res.status;