From 1bd962d9f9037ed20fdf588d3b91ce36567f4867 Mon Sep 17 00:00:00 2001 From: anonimal Date: Fri, 6 Sep 2019 23:11:37 +0000 Subject: wallet2: resolve CID 203918 null pointer deference (NULL_RETURNS) --- src/wallet/wallet2.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index b99fc12e2..009a0441f 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -13143,6 +13143,12 @@ bool wallet2::save_to_file(const std::string& path_to_file, const std::string& r } FILE *fp = fopen(path_to_file.c_str(), "w+"); + if (!fp) + { + MERROR("Failed to open wallet file for writing: " << path_to_file << ": " << strerror(errno)); + return false; + } + // Save the result b/c we need to close the fp before returning success/failure. int write_result = PEM_write(fp, ASCII_OUTPUT_MAGIC.c_str(), "", (const unsigned char *) raw.c_str(), raw.length()); fclose(fp); -- cgit v1.2.3 From d099658522c6f17055a3b9977f74c6e91c6c8199 Mon Sep 17 00:00:00 2001 From: anonimal Date: Sat, 7 Sep 2019 00:29:09 +0000 Subject: bootstrap_daemon: resolve CID 203915 (UNCAUGHT_EXCEPT) The issue is triggered by the captured `this` in RPC server, which passes reference to throwable `core_rpc_server`: `core_rpc_server.cpp:164: m_bootstrap_daemon.reset(new bootstrap_daemon([this]{ return get_random_public_node(); }));` The solution is to simply remove noexcept from the remaining `bootstrap_daemon` constructors because noexcept is false in this context. >"An exception of type "boost::exception_detail::clone_impl>" is thrown but the throw list "noexcept" doesn't allow it to be thrown. This will cause a call to unexpected() which usually calls terminate()." --- src/rpc/bootstrap_daemon.cpp | 2 +- src/rpc/bootstrap_daemon.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/rpc/bootstrap_daemon.cpp b/src/rpc/bootstrap_daemon.cpp index 6f8426ee7..c97b2c95a 100644 --- a/src/rpc/bootstrap_daemon.cpp +++ b/src/rpc/bootstrap_daemon.cpp @@ -12,7 +12,7 @@ namespace cryptonote { - bootstrap_daemon::bootstrap_daemon(std::function()> get_next_public_node) noexcept + bootstrap_daemon::bootstrap_daemon(std::function()> get_next_public_node) : m_get_next_public_node(get_next_public_node) { } diff --git a/src/rpc/bootstrap_daemon.h b/src/rpc/bootstrap_daemon.h index 130a6458d..6276b1b21 100644 --- a/src/rpc/bootstrap_daemon.h +++ b/src/rpc/bootstrap_daemon.h @@ -15,7 +15,7 @@ namespace cryptonote class bootstrap_daemon { public: - bootstrap_daemon(std::function()> get_next_public_node) noexcept; + bootstrap_daemon(std::function()> get_next_public_node); bootstrap_daemon(const std::string &address, const boost::optional &credentials); std::string address() const noexcept; -- cgit v1.2.3