From 83efe4a5200d3ad33c6373f92600488cb3ea02bd Mon Sep 17 00:00:00 2001 From: Jamal Natour Date: Sat, 8 Apr 2017 16:34:29 +0100 Subject: [PATCH 1/2] Patch: explicit nullptr to make it easier to see the issue --- include/boost/asio/generic/detail/impl/endpoint.ipp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/asio/generic/detail/impl/endpoint.ipp b/include/boost/asio/generic/detail/impl/endpoint.ipp index 3c2da4a6..c5e573f6 100644 --- a/include/boost/asio/generic/detail/impl/endpoint.ipp +++ b/include/boost/asio/generic/detail/impl/endpoint.ipp @@ -34,7 +34,7 @@ namespace detail { endpoint::endpoint() { - init(0, 0, 0); + init(nullptr, 0, 0); } endpoint::endpoint(const void* sock_addr, From 0bbcfe44c647fdcc91d76f17c454685659855402 Mon Sep 17 00:00:00 2001 From: Jamal Natour Date: Sat, 8 Apr 2017 16:35:05 +0100 Subject: [PATCH 2/2] Patch: fixes nullptr deref in memcpy --- include/boost/asio/generic/detail/impl/endpoint.ipp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/boost/asio/generic/detail/impl/endpoint.ipp b/include/boost/asio/generic/detail/impl/endpoint.ipp index c5e573f6..080094ce 100644 --- a/include/boost/asio/generic/detail/impl/endpoint.ipp +++ b/include/boost/asio/generic/detail/impl/endpoint.ipp @@ -95,7 +95,11 @@ void endpoint::init(const void* sock_addr, using namespace std; // For memset and memcpy. memset(&data_.generic, 0, sizeof(boost::asio::detail::sockaddr_storage_type)); - memcpy(&data_.generic, sock_addr, sock_addr_size); + // init(null_ptr,0,0) results in sock_addr being nullptr + if(sock_addr) + { + memcpy(&data_.generic, sock_addr, sock_addr_size); + } size_ = sock_addr_size; protocol_ = sock_protocol;