Skip to content

Commit

Permalink
multiplexed_socket: Fix memcpy() of nullptr
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
Olivier Dion authored and aberaud committed Jun 9, 2021
1 parent cafa0c9 commit 2b18587
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/jamidht/multiplexed_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,8 @@ MultiplexedSocket::write(const uint16_t& channel,
std::size_t len,
std::error_code& ec)
{
assert(nullptr != buf);

if (pimpl_->isShutdown_) {
ec = std::make_error_code(std::errc::broken_pipe);
return -1;
Expand Down Expand Up @@ -942,7 +944,8 @@ ChannelSocket::shutdown()
stop();
if (auto ep = pimpl_->endpoint.lock()) {
std::error_code ec;
ep->write(pimpl_->channel, nullptr, 0, ec);
const uint8_t dummy = '\0';
ep->write(pimpl_->channel, &dummy, 0, ec);
}
}

Expand Down

0 comments on commit 2b18587

Please sign in to comment.