Skip to content
Snippets Groups Projects
Commit 2b185875 authored by Olivier Dion's avatar Olivier Dion Committed by Adrien Béraud
Browse files

multiplexed_socket: Fix memcpy() of nullptr

`memcpy()` has the `__nonnull__` and ASAN doesn't like it even tho the length
of the buffer is 0.  Thus, using a dummy buffer on the stack.

--------------------------------------------------------------------------------
#0 0x55555a0a1b8a in /usr/include/msgpack/v1/sbuffer.hpp:74
#1 0x55555a1dcfd3 in /usr/include/msgpack/v1/pack.hpp:623
#3 0x55555a11eab2 in /usr/include/msgpack/v1/pack.hpp:1311
#4 0x55555a35c1c5 in /ring-project/daemon/src/jamidht/multiplexed_socket.cpp:676
#5 0x55555a363879 in /ring-project/daemon/src/jamidht/multiplexed_socket.cpp:945
#6 0x55555a35554e in /ring-project/daemon/src/jamidht/multiplexed_socket.cpp:459
#7 0x55555a34e0c0 in /ring-project/daemon/src/jamidht/multiplexed_socket.cpp:247
#8 0x55555a37298f in /ring-project/daemon/src/jamidht/multiplexed_socket.cpp:75
(...)
--------------------------------------------------------------------------------

Change-Id: Ibc8c8d808c233da1649f556466b24d68decf85e8
parent cafa0c9e
No related branches found
No related tags found
No related merge requests found
...@@ -658,6 +658,8 @@ MultiplexedSocket::write(const uint16_t& channel, ...@@ -658,6 +658,8 @@ MultiplexedSocket::write(const uint16_t& channel,
std::size_t len, std::size_t len,
std::error_code& ec) std::error_code& ec)
{ {
assert(nullptr != buf);
if (pimpl_->isShutdown_) { if (pimpl_->isShutdown_) {
ec = std::make_error_code(std::errc::broken_pipe); ec = std::make_error_code(std::errc::broken_pipe);
return -1; return -1;
...@@ -942,7 +944,8 @@ ChannelSocket::shutdown() ...@@ -942,7 +944,8 @@ ChannelSocket::shutdown()
stop(); stop();
if (auto ep = pimpl_->endpoint.lock()) { if (auto ep = pimpl_->endpoint.lock()) {
std::error_code ec; std::error_code ec;
ep->write(pimpl_->channel, nullptr, 0, ec); const uint8_t dummy = '\0';
ep->write(pimpl_->channel, &dummy, 0, ec);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment