#2120 closed Bugs (fixed)
Asio local domain sockets crop senders abstract path name.
Reported by: | Owned by: | chris_kohlhoff | |
---|---|---|---|
Milestone: | Boost 1.36.0 | Component: | asio |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | asio local domain | Cc: |
Description
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
Change History (3)
comment:1 by , 14 years ago
Milestone: | Boost 1.35.1 → Boost 1.36.0 |
---|---|
Status: | new → assigned |
comment:2 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:3 by , 14 years ago
(In [47674]) Merged revisions 47673 via svnmerge from https://svn.boost.org/svn/boost/trunk
........
r47673 | chris_kohlhoff | 2008-07-22 18:26:35 +1000 (Tue, 22 Jul 2008) | 3 lines
Correct an array bounds error in the treatment of paths for UNIX domain sockets. Fixes #2120.
........
(In [47673]) Correct an array bounds error in the treatment of paths for UNIX domain sockets. Fixes #2120.