Subject: [Boost-bugs] [Boost C++ Libraries] #2120: Asio local domain sockets crop senders abstract path name.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-07-16 06:31:52
#2120: Asio local domain sockets crop senders abstract path name.
-------------------------------------+--------------------------------------
Reporter: skv_at_[hidden] | Owner: chris_kohlhoff
Type: Bugs | Status: new
Milestone: Boost 1.35.1 | Component: asio
Version: Boost Development Trunk | Severity: Problem
Keywords: asio local domain |
-------------------------------------+--------------------------------------
I'm experiencing that, when using abstract socket names with Asio/Local,
the last character in the senders path name gets cropped.
The senders full path name is received by
reactive_socket_service::receive_operation::receive_from, but after the
receive action, a resize function is called on the endpoint object. The
basic_endpoint::resize then calculates the path length to be one character
to few.
{{{
/// Set the underlying size of the endpoint in the native type.
void basic_endpoint::resize(std::size_t size)
{
if (size > sizeof(boost::asio::detail::sockaddr_un_type))
{
boost::system::system_error e(boost::asio::error::invalid_argument);
boost::throw_exception(e);
}
else if (size == 0)
{
path_length_ = 0;
}
else
{
path_length_ = size
- offsetof(boost::asio::detail::sockaddr_un_type, sun_path);
// The path returned by the operating system may be NUL-terminated.
if (path_length_ > 0 && data_.local.sun_path[path_length_] == 0)
--path_length_;
}
}
}}}
I guess the last part should have been
{{{
if (path_length_ > 0 && data_.local.sun_path[path_length_-1] == 0)
--path_length_;
}}}
Btw. if using non-abstract names the name is not cropped, but indexing
past the path name terminating character can be observed when adjusting
path length.
Changing the zero termination indexing makes both abstract and non-
abstract names pass unaltered...
br/thanx
Jan
-- Ticket URL: <http://svn.boost.org/trac/boost/ticket/2120> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC