aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/CMakeLists.txt2
-rw-r--r--contrib/epee/CMakeLists.txt2
-rw-r--r--contrib/epee/include/hex.h2
-rw-r--r--contrib/epee/include/memwipe.h18
-rw-r--r--contrib/epee/include/misc_os_dependent.h4
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.h2
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.inl5
-rw-r--r--contrib/epee/include/net/connection_basic.hpp2
-rw-r--r--contrib/epee/include/net/http_auth.h2
-rw-r--r--contrib/epee/include/net/levin_protocol_handler_async.h94
-rw-r--r--contrib/epee/include/net/network_throttle-detail.hpp2
-rw-r--r--contrib/epee/include/net/network_throttle.hpp2
-rw-r--r--contrib/epee/include/span.h4
-rw-r--r--contrib/epee/include/storages/http_abstract_invoke.h2
-rw-r--r--contrib/epee/include/storages/levin_abstract_invoke2.h28
-rw-r--r--contrib/epee/include/string_tools.h9
-rw-r--r--contrib/epee/include/wipeable_string.h5
-rw-r--r--contrib/epee/src/CMakeLists.txt2
-rw-r--r--contrib/epee/src/connection_basic.cpp2
-rw-r--r--contrib/epee/src/hex.cpp2
-rw-r--r--contrib/epee/src/http_auth.cpp2
-rw-r--r--contrib/epee/src/memwipe.c9
-rw-r--r--contrib/epee/src/network_throttle-detail.cpp2
-rw-r--r--contrib/epee/src/network_throttle.cpp2
-rw-r--r--contrib/epee/src/readline_buffer.cpp1
-rw-r--r--contrib/epee/src/wipeable_string.cpp18
26 files changed, 126 insertions, 99 deletions
diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt
index e7c501ed2..990a05c08 100644
--- a/contrib/CMakeLists.txt
+++ b/contrib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2017, The Monero Project
+# Copyright (c) 2014-2018, The Monero Project
#
# All rights reserved.
#
diff --git a/contrib/epee/CMakeLists.txt b/contrib/epee/CMakeLists.txt
index e7ff6001b..035b24b36 100644
--- a/contrib/epee/CMakeLists.txt
+++ b/contrib/epee/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2017, The Monero Project
+# Copyright (c) 2014-2018, The Monero Project
#
# All rights reserved.
#
diff --git a/contrib/epee/include/hex.h b/contrib/epee/include/hex.h
index f8d6be048..e960da1d2 100644
--- a/contrib/epee/include/hex.h
+++ b/contrib/epee/include/hex.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017, The Monero Project
+// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/include/memwipe.h b/contrib/epee/include/memwipe.h
index c3b4ce8ab..0d8f491b7 100644
--- a/contrib/epee/include/memwipe.h
+++ b/contrib/epee/include/memwipe.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017, The Monero Project
+// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
@@ -67,18 +67,14 @@ namespace tools {
}
};
+ template<typename T>
+ T& unwrap(scrubbed<T>& src) { return src; }
+
+ template<typename T>
+ const T& unwrap(scrubbed<T> const& src) { return src; }
+
template <class T, size_t N>
using scrubbed_arr = scrubbed<std::array<T, N>>;
} // namespace tools
-// Partial specialization for std::is_pod<tools::scrubbed<T>> so that it can
-// pretend to be the containted type in those contexts.
-namespace std
-{
- template<class t_scrubbee>
- struct is_pod<tools::scrubbed<t_scrubbee>> {
- static const bool value = is_pod<t_scrubbee>::value;
- };
-}
-
#endif // __cplusplus
diff --git a/contrib/epee/include/misc_os_dependent.h b/contrib/epee/include/misc_os_dependent.h
index 99690b301..ffe575501 100644
--- a/contrib/epee/include/misc_os_dependent.h
+++ b/contrib/epee/include/misc_os_dependent.h
@@ -75,13 +75,13 @@ namespace misc_utils
clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
- return (mts.tv_sec * 1000000000) + (mts.tv_nsec);
+ return ((uint64_t)mts.tv_sec * 1000000000) + (mts.tv_nsec);
#else
struct timespec ts;
if(clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
return 0;
}
- return (ts.tv_sec * 1000000000) + (ts.tv_nsec);
+ return ((uint64_t)ts.tv_sec * 1000000000) + (ts.tv_nsec);
#endif
}
diff --git a/contrib/epee/include/net/abstract_tcp_server2.h b/contrib/epee/include/net/abstract_tcp_server2.h
index c0401c8b0..ccde928ba 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.h
+++ b/contrib/epee/include/net/abstract_tcp_server2.h
@@ -207,7 +207,7 @@ namespace net_utils
bool connect(const std::string& adr, const std::string& port, uint32_t conn_timeot, t_connection_context& cn, const std::string& bind_ip = "0.0.0.0");
template<class t_callback>
- bool connect_async(const std::string& adr, const std::string& port, uint32_t conn_timeot, t_callback cb, const std::string& bind_ip = "0.0.0.0");
+ bool connect_async(const std::string& adr, const std::string& port, uint32_t conn_timeot, const t_callback &cb, const std::string& bind_ip = "0.0.0.0");
typename t_protocol_handler::config_type& get_config_object(){return m_config;}
diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl
index 870f6c2b2..195ee2f0c 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.inl
+++ b/contrib/epee/include/net/abstract_tcp_server2.inl
@@ -935,6 +935,9 @@ POP_WARNINGS
boost::bind(&boosted_tcp_server<t_protocol_handler>::handle_accept, this,
boost::asio::placeholders::error));
+ boost::asio::socket_base::keep_alive opt(true);
+ conn->socket().set_option(opt);
+
conn->start(true, 1 < m_threads_count);
conn->save_dbg_log();
}else
@@ -1055,7 +1058,7 @@ POP_WARNINGS
}
//---------------------------------------------------------------------------------
template<class t_protocol_handler> template<class t_callback>
- bool boosted_tcp_server<t_protocol_handler>::connect_async(const std::string& adr, const std::string& port, uint32_t conn_timeout, t_callback cb, const std::string& bind_ip)
+ bool boosted_tcp_server<t_protocol_handler>::connect_async(const std::string& adr, const std::string& port, uint32_t conn_timeout, const t_callback &cb, const std::string& bind_ip)
{
TRY_ENTRY();
connection_ptr new_connection_l(new connection<t_protocol_handler>(io_service_, m_config, m_sock_count, m_sock_number, m_pfilter, m_connection_type) );
diff --git a/contrib/epee/include/net/connection_basic.hpp b/contrib/epee/include/net/connection_basic.hpp
index 16de469a7..095e747a5 100644
--- a/contrib/epee/include/net/connection_basic.hpp
+++ b/contrib/epee/include/net/connection_basic.hpp
@@ -8,7 +8,7 @@
// ! (how ever if in some wonderful juristdictions that is not the case, then why not make another sub-class withat that members and licence it as epee part)
// ! Working on above premise, IF this is valid in your juristdictions, then consider this code as released as:
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/include/net/http_auth.h b/contrib/epee/include/net/http_auth.h
index 71f56b570..4324c41fd 100644
--- a/contrib/epee/include/net/http_auth.h
+++ b/contrib/epee/include/net/http_auth.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h
index 5b825cef9..0b1fe05fa 100644
--- a/contrib/epee/include/net/levin_protocol_handler_async.h
+++ b/contrib/epee/include/net/levin_protocol_handler_async.h
@@ -77,6 +77,8 @@ class async_protocol_handler_config
levin_commands_handler<t_connection_context>* m_pcommands_handler;
void (*m_pcommands_handler_destroy)(levin_commands_handler<t_connection_context>*);
+ void delete_connections (size_t count, bool incoming);
+
public:
typedef t_connection_context connection_context;
uint64_t m_max_packet_size;
@@ -84,16 +86,16 @@ public:
int invoke(int command, const std::string& in_buff, std::string& buff_out, boost::uuids::uuid connection_id);
template<class callback_t>
- int invoke_async(int command, const std::string& in_buff, boost::uuids::uuid connection_id, callback_t cb, size_t timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED);
+ int invoke_async(int command, const std::string& in_buff, boost::uuids::uuid connection_id, const callback_t &cb, size_t timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED);
int notify(int command, const std::string& in_buff, boost::uuids::uuid connection_id);
bool close(boost::uuids::uuid connection_id);
bool update_connection_context(const t_connection_context& contxt);
bool request_callback(boost::uuids::uuid connection_id);
template<class callback_t>
- bool foreach_connection(callback_t cb);
+ bool foreach_connection(const callback_t &cb);
template<class callback_t>
- bool for_connection(const boost::uuids::uuid &connection_id, callback_t cb);
+ bool for_connection(const boost::uuids::uuid &connection_id, const callback_t &cb);
size_t get_connections_count();
void set_handler(levin_commands_handler<t_connection_context>* handler, void (*destroy)(levin_commands_handler<t_connection_context>*) = NULL);
@@ -101,6 +103,7 @@ public:
{}
~async_protocol_handler_config() { set_handler(NULL, NULL); }
void del_out_connections(size_t count);
+ void del_in_connections(size_t count);
};
@@ -245,7 +248,7 @@ public:
std::list<boost::shared_ptr<invoke_response_handler_base> > m_invoke_response_handlers;
template<class callback_t>
- bool add_invoke_response_handler(callback_t cb, uint64_t timeout, async_protocol_handler& con, int command)
+ bool add_invoke_response_handler(const callback_t &cb, uint64_t timeout, async_protocol_handler& con, int command)
{
CRITICAL_REGION_LOCAL(m_invoke_response_handlers_lock);
boost::shared_ptr<invoke_response_handler_base> handler(boost::make_shared<anvoke_handler<callback_t>>(cb, timeout, con, command));
@@ -529,7 +532,7 @@ public:
}
template<class callback_t>
- bool async_invoke(int command, const std::string& in_buff, callback_t cb, size_t timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
+ bool async_invoke(int command, const std::string& in_buff, const callback_t &cb, size_t timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
{
misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler(
boost::bind(&async_protocol_handler::finish_outer_call, this));
@@ -731,41 +734,50 @@ void async_protocol_handler_config<t_connection_context>::del_connection(async_p
}
//------------------------------------------------------------------------------------------
template<class t_connection_context>
+void async_protocol_handler_config<t_connection_context>::delete_connections(size_t count, bool incoming)
+{
+ std::vector <boost::uuids::uuid> connections;
+ CRITICAL_REGION_BEGIN(m_connects_lock);
+ for (auto& c: m_connects)
+ {
+ if (c.second->m_connection_context.m_is_income == incoming)
+ connections.push_back(c.first);
+ }
+
+ // close random connections from the provided set
+ // TODO or better just keep removing random elements (performance)
+ unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
+ shuffle(connections.begin(), connections.end(), std::default_random_engine(seed));
+ while (count > 0 && connections.size() > 0)
+ {
+ try
+ {
+ auto i = connections.end() - 1;
+ async_protocol_handler<t_connection_context> *conn = m_connects.at(*i);
+ del_connection(conn);
+ close(*i);
+ connections.erase(i);
+ }
+ catch (const std::out_of_range &e)
+ {
+ MWARNING("Connection not found in m_connects, continuing");
+ }
+ --count;
+ }
+
+ CRITICAL_REGION_END();
+}
+//------------------------------------------------------------------------------------------
+template<class t_connection_context>
void async_protocol_handler_config<t_connection_context>::del_out_connections(size_t count)
{
- std::vector <boost::uuids::uuid> out_connections;
- CRITICAL_REGION_BEGIN(m_connects_lock);
- for (auto& c: m_connects)
- {
- if (!c.second->m_connection_context.m_is_income)
- out_connections.push_back(c.first);
- }
-
- if (out_connections.size() == 0)
- return;
-
- // close random out connections
- // TODO or better just keep removing random elements (performance)
- unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
- shuffle(out_connections.begin(), out_connections.end(), std::default_random_engine(seed));
- while (count > 0 && out_connections.size() > 0)
- {
- try
- {
- auto i = out_connections.begin();
- async_protocol_handler<t_connection_context> *conn = m_connects.at(*i);
- del_connection(conn);
- close(*i);
- out_connections.erase(i);
- }
- catch (const std::out_of_range &e)
- {
- MWARNING("Connection not found in m_connects, continuing");
- }
- --count;
- }
-
- CRITICAL_REGION_END();
+ delete_connections(count, false);
+}
+//------------------------------------------------------------------------------------------
+template<class t_connection_context>
+void async_protocol_handler_config<t_connection_context>::del_in_connections(size_t count)
+{
+ delete_connections(count, true);
}
//------------------------------------------------------------------------------------------
template<class t_connection_context>
@@ -805,7 +817,7 @@ int async_protocol_handler_config<t_connection_context>::invoke(int command, con
}
//------------------------------------------------------------------------------------------
template<class t_connection_context> template<class callback_t>
-int async_protocol_handler_config<t_connection_context>::invoke_async(int command, const std::string& in_buff, boost::uuids::uuid connection_id, callback_t cb, size_t timeout)
+int async_protocol_handler_config<t_connection_context>::invoke_async(int command, const std::string& in_buff, boost::uuids::uuid connection_id, const callback_t &cb, size_t timeout)
{
async_protocol_handler<t_connection_context>* aph;
int r = find_and_lock_connection(connection_id, aph);
@@ -813,7 +825,7 @@ int async_protocol_handler_config<t_connection_context>::invoke_async(int comman
}
//------------------------------------------------------------------------------------------
template<class t_connection_context> template<class callback_t>
-bool async_protocol_handler_config<t_connection_context>::foreach_connection(callback_t cb)
+bool async_protocol_handler_config<t_connection_context>::foreach_connection(const callback_t &cb)
{
CRITICAL_REGION_LOCAL(m_connects_lock);
for(auto& c: m_connects)
@@ -826,7 +838,7 @@ bool async_protocol_handler_config<t_connection_context>::foreach_connection(cal
}
//------------------------------------------------------------------------------------------
template<class t_connection_context> template<class callback_t>
-bool async_protocol_handler_config<t_connection_context>::for_connection(const boost::uuids::uuid &connection_id, callback_t cb)
+bool async_protocol_handler_config<t_connection_context>::for_connection(const boost::uuids::uuid &connection_id, const callback_t &cb)
{
CRITICAL_REGION_LOCAL(m_connects_lock);
async_protocol_handler<t_connection_context>* aph = find_connection(connection_id);
diff --git a/contrib/epee/include/net/network_throttle-detail.hpp b/contrib/epee/include/net/network_throttle-detail.hpp
index dba15a5ed..955668d62 100644
--- a/contrib/epee/include/net/network_throttle-detail.hpp
+++ b/contrib/epee/include/net/network_throttle-detail.hpp
@@ -2,7 +2,7 @@
/// @author rfree (current maintainer in monero.cc project)
/// @brief implementaion for throttling of connection (count and rate-limit speed etc)
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/include/net/network_throttle.hpp b/contrib/epee/include/net/network_throttle.hpp
index 225ffee04..7df79a908 100644
--- a/contrib/epee/include/net/network_throttle.hpp
+++ b/contrib/epee/include/net/network_throttle.hpp
@@ -2,7 +2,7 @@
/// @author rfree (current maintainer in monero.cc project)
/// @brief interface for throttling of connection (count and rate-limit speed etc)
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/include/span.h b/contrib/epee/include/span.h
index 5660c09d1..452cc088f 100644
--- a/contrib/epee/include/span.h
+++ b/contrib/epee/include/span.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017, The Monero Project
+// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
@@ -108,7 +108,7 @@ namespace epee
template<typename T>
constexpr bool has_padding() noexcept
{
- return !std::is_pod<T>::value || alignof(T) != 1;
+ return !std::is_standard_layout<T>() || alignof(T) != 1;
}
//! \return Cast data from `src` as `span<const std::uint8_t>`.
diff --git a/contrib/epee/include/storages/http_abstract_invoke.h b/contrib/epee/include/storages/http_abstract_invoke.h
index 6517f1253..d93084ab0 100644
--- a/contrib/epee/include/storages/http_abstract_invoke.h
+++ b/contrib/epee/include/storages/http_abstract_invoke.h
@@ -115,7 +115,7 @@ namespace epee
}
if(resp_t.error.code || resp_t.error.message.size())
{
- LOG_ERROR("RPC call of \"" << method_name << "\" returned error: " << resp_t.error.code << ", message: " << resp_t.error.message);
+ LOG_ERROR("RPC call of \"" << req_t.method << "\" returned error: " << resp_t.error.code << ", message: " << resp_t.error.message);
return false;
}
result_struct = resp_t.result;
diff --git a/contrib/epee/include/storages/levin_abstract_invoke2.h b/contrib/epee/include/storages/levin_abstract_invoke2.h
index 8ced9d689..d77e7a1f8 100644
--- a/contrib/epee/include/storages/levin_abstract_invoke2.h
+++ b/contrib/epee/include/storages/levin_abstract_invoke2.h
@@ -60,8 +60,7 @@ namespace epee
LOG_ERROR("Failed to load_from_binary on command " << command);
return false;
}
- result_struct.load(stg_ret);
- return true;
+ return result_struct.load(stg_ret);
}
template<class t_arg, class t_transport>
@@ -105,13 +104,11 @@ namespace epee
LOG_ERROR("Failed to load_from_binary on command " << command);
return false;
}
- result_struct.load(stg_ret);
-
- return true;
+ return result_struct.load(stg_ret);
}
template<class t_result, class t_arg, class callback_t, class t_transport>
- bool async_invoke_remote_command2(boost::uuids::uuid conn_id, int command, const t_arg& out_struct, t_transport& transport, callback_t cb, size_t inv_timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
+ bool async_invoke_remote_command2(boost::uuids::uuid conn_id, int command, const t_arg& out_struct, t_transport& transport, const callback_t &cb, size_t inv_timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
{
typename serialization::portable_storage stg;
const_cast<t_arg&>(out_struct).store(stg);//TODO: add true const support to searilzation
@@ -133,7 +130,12 @@ namespace epee
cb(LEVIN_ERROR_FORMAT, result_struct, context);
return false;
}
- result_struct.load(stg_ret);
+ if (!result_struct.load(stg_ret))
+ {
+ LOG_ERROR("Failed to load result struct on command " << command);
+ cb(LEVIN_ERROR_FORMAT, result_struct, context);
+ return false;
+ }
cb(code, result_struct, context);
return true;
}, inv_timeout);
@@ -176,7 +178,11 @@ namespace epee
boost::value_initialized<t_in_type> in_struct;
boost::value_initialized<t_out_type> out_struct;
- static_cast<t_in_type&>(in_struct).load(strg);
+ if (!static_cast<t_in_type&>(in_struct).load(strg))
+ {
+ LOG_ERROR("Failed to load in_struct in command " << command);
+ return -1;
+ }
int res = cb(command, static_cast<t_in_type&>(in_struct), static_cast<t_out_type&>(out_struct), context);
serialization::portable_storage strg_out;
static_cast<t_out_type&>(out_struct).store(strg_out);
@@ -200,7 +206,11 @@ namespace epee
return -1;
}
boost::value_initialized<t_in_type> in_struct;
- static_cast<t_in_type&>(in_struct).load(strg);
+ if (!static_cast<t_in_type&>(in_struct).load(strg))
+ {
+ LOG_ERROR("Failed to load in_struct in notify " << command);
+ return -1;
+ }
return cb(command, in_struct, context);
}
diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h
index 5a1ef0743..63705e401 100644
--- a/contrib/epee/include/string_tools.h
+++ b/contrib/epee/include/string_tools.h
@@ -45,6 +45,7 @@
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include "hex.h"
+#include "memwipe.h"
#include "span.h"
#include "warnings.h"
@@ -330,7 +331,7 @@ POP_WARNINGS
template<class t_pod_type>
std::string pod_to_hex(const t_pod_type& s)
{
- static_assert(std::is_pod<t_pod_type>::value, "expected pod type");
+ static_assert(std::is_standard_layout<t_pod_type>(), "expected standard layout type");
return to_hex::string(as_byte_span(s));
}
//----------------------------------------------------------------------------
@@ -351,6 +352,12 @@ POP_WARNINGS
return true;
}
//----------------------------------------------------------------------------
+ template<class t_pod_type>
+ bool hex_to_pod(const std::string& hex_str, tools::scrubbed<t_pod_type>& s)
+ {
+ return hex_to_pod(hex_str, unwrap(s));
+ }
+ //----------------------------------------------------------------------------
bool validate_hex(uint64_t length, const std::string& str);
//----------------------------------------------------------------------------
inline std::string get_extension(const std::string& str)
diff --git a/contrib/epee/include/wipeable_string.h b/contrib/epee/include/wipeable_string.h
index 66d3e8e2b..70d1a9586 100644
--- a/contrib/epee/include/wipeable_string.h
+++ b/contrib/epee/include/wipeable_string.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017, The Monero Project
+// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
@@ -58,13 +58,10 @@ namespace epee
wipeable_string &operator=(wipeable_string &&other);
wipeable_string &operator=(const wipeable_string &other);
- static void set_wipe(void *(*f)(void*, size_t)) { wipefunc = f; }
-
private:
void grow(size_t sz, size_t reserved = 0);
private:
std::vector<char> buffer;
- static void *(*wipefunc)(void*, size_t);
};
}
diff --git a/contrib/epee/src/CMakeLists.txt b/contrib/epee/src/CMakeLists.txt
index 538c7ce91..c4750cea0 100644
--- a/contrib/epee/src/CMakeLists.txt
+++ b/contrib/epee/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2017, The Monero Project
+# Copyright (c) 2014-2018, The Monero Project
#
# All rights reserved.
#
diff --git a/contrib/epee/src/connection_basic.cpp b/contrib/epee/src/connection_basic.cpp
index 5848d1268..dea1928a7 100644
--- a/contrib/epee/src/connection_basic.cpp
+++ b/contrib/epee/src/connection_basic.cpp
@@ -2,7 +2,7 @@
/// @author rfree (current maintainer in monero.cc project)
/// @brief base for connection, contains e.g. the ratelimit hooks
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/src/hex.cpp b/contrib/epee/src/hex.cpp
index cfbd3cf87..c143b2dc2 100644
--- a/contrib/epee/src/hex.cpp
+++ b/contrib/epee/src/hex.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017, The Monero Project
+// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/src/http_auth.cpp b/contrib/epee/src/http_auth.cpp
index 5b8d892ff..dc968d971 100644
--- a/contrib/epee/src/http_auth.cpp
+++ b/contrib/epee/src/http_auth.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/src/memwipe.c b/contrib/epee/src/memwipe.c
index da7e9f346..e3a2f76c8 100644
--- a/contrib/epee/src/memwipe.c
+++ b/contrib/epee/src/memwipe.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2017, The Monero Project
+// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
@@ -31,6 +31,8 @@
#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>
#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
#ifdef HAVE_EXPLICIT_BZERO
#include <strings.h>
#endif
@@ -50,7 +52,12 @@ void *memwipe(void *ptr, size_t n)
{
if (memset_s(ptr, n, 0, n))
{
+#ifdef NDEBUG
+ fprintf(stderr, "Error: memset_s failed\n");
+ _exit(1);
+#else
abort();
+#endif
}
SCARECROW // might as well...
return ptr;
diff --git a/contrib/epee/src/network_throttle-detail.cpp b/contrib/epee/src/network_throttle-detail.cpp
index ed6bc07ed..7eeade3a1 100644
--- a/contrib/epee/src/network_throttle-detail.cpp
+++ b/contrib/epee/src/network_throttle-detail.cpp
@@ -2,7 +2,7 @@
/// @author rfree (current maintainer in monero.cc project)
/// @brief implementaion for throttling of connection (count and rate-limit speed etc)
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/src/network_throttle.cpp b/contrib/epee/src/network_throttle.cpp
index dd1640a2e..167738855 100644
--- a/contrib/epee/src/network_throttle.cpp
+++ b/contrib/epee/src/network_throttle.cpp
@@ -26,7 +26,7 @@ Throttling work by:
*/
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/contrib/epee/src/readline_buffer.cpp b/contrib/epee/src/readline_buffer.cpp
index 00c2ddd62..076a63612 100644
--- a/contrib/epee/src/readline_buffer.cpp
+++ b/contrib/epee/src/readline_buffer.cpp
@@ -1,7 +1,6 @@
#include "readline_buffer.h"
#include <readline/readline.h>
#include <readline/history.h>
-#include <sys/select.h>
#include <unistd.h>
#include <iostream>
#include <boost/thread.hpp>
diff --git a/contrib/epee/src/wipeable_string.cpp b/contrib/epee/src/wipeable_string.cpp
index 08a975e58..cc43b8988 100644
--- a/contrib/epee/src/wipeable_string.cpp
+++ b/contrib/epee/src/wipeable_string.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017, The Monero Project
+// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
@@ -27,14 +27,13 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <string.h>
+#include "memwipe.h"
#include "misc_log_ex.h"
#include "wipeable_string.h"
namespace epee
{
-void *(*wipeable_string::wipefunc)(void*, size_t) = NULL;
-
wipeable_string::wipeable_string(const wipeable_string &other):
buffer(other.buffer)
{
@@ -55,12 +54,11 @@ wipeable_string::wipeable_string(const std::string &other)
wipeable_string::wipeable_string(std::string &&other)
{
- CHECK_AND_ASSERT_THROW_MES(wipefunc, "wipefunc is not set");
grow(other.size());
memcpy(buffer.data(), other.c_str(), size());
if (!other.empty())
{
- wipefunc(&other[0], other.size()); // we're kinda left with this again aren't we
+ memwipe(&other[0], other.size()); // we're kinda left with this again aren't we
other = std::string();
}
}
@@ -78,30 +76,28 @@ wipeable_string::~wipeable_string()
void wipeable_string::wipe()
{
- CHECK_AND_ASSERT_THROW_MES(wipefunc, "wipefunc is not set");
- wipefunc(buffer.data(), buffer.size() * sizeof(char));
+ memwipe(buffer.data(), buffer.size() * sizeof(char));
}
void wipeable_string::grow(size_t sz, size_t reserved)
{
- CHECK_AND_ASSERT_THROW_MES(wipefunc, "wipefunc is not set");
if (reserved < sz)
reserved = sz;
if (reserved <= buffer.capacity())
{
if (sz < buffer.size())
- wipefunc(buffer.data() + sz, buffer.size() - sz);
+ memwipe(buffer.data() + sz, buffer.size() - sz);
buffer.resize(sz);
return;
}
size_t old_sz = buffer.size();
std::unique_ptr<char[]> tmp{new char[old_sz]};
memcpy(tmp.get(), buffer.data(), old_sz * sizeof(char));
- wipefunc(buffer.data(), old_sz * sizeof(char));
+ memwipe(buffer.data(), old_sz * sizeof(char));
buffer.reserve(reserved);
buffer.resize(sz);
memcpy(buffer.data(), tmp.get(), old_sz * sizeof(char));
- wipefunc(tmp.get(), old_sz * sizeof(char));
+ memwipe(tmp.get(), old_sz * sizeof(char));
}
void wipeable_string::push_back(char c)