summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVernon Mauery <vernon.mauery@linux.intel.com>2018-12-18 16:11:38 -0800
committerVernon Mauery <vernon.mauery@linux.intel.com>2018-12-19 15:21:26 -0800
commit744b3c8b840a13ed4a6c07836ead4a0c88911437 (patch)
tree007ec8204fa260de4ae141c4281e995d0a3a1a8d
parentd91fd9d28515983ef23de39c459c927c445f6a1a (diff)
downloadphosphor-net-ipmid-744b3c8b840a13ed4a6c07836ead4a0c88911437.tar.gz
phosphor-net-ipmid-744b3c8b840a13ed4a6c07836ead4a0c88911437.zip
phosphor-net-ipmid: connect with the correct sockaddr size
Abstract unix sockets start with the nul-charater, but are not nul terminated. In fact, the nul-character has no meaning in the path. According to the man page unix(7), abstract: an abstract socket address is distinguished (from a pathname socket) by the fact that sun_path[0] is a null byte ('\0'). The socket's address in this namespace is given by the additional bytes in sun_path that are covered by the specified length of the address structure. (Null bytes in the name have no special significance.) This means that when calling bind/connect, the size of the sockaddr structure is not sizeof(sockaddr_un), it is sizeof(sockaddr_un) - sizeof(sun_path) + (path_len) Change-Id: I61f967d9215afb00e9e5c22f535f5c252b41d3af Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
-rw-r--r--sol/sol_manager.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/sol/sol_manager.cpp b/sol/sol_manager.cpp
index 66d2b49..859f371 100644
--- a/sol/sol_manager.cpp
+++ b/sol/sol_manager.cpp
@@ -45,7 +45,9 @@ void Manager::initHostConsoleFd()
consoleFD = std::make_unique<CustomFD>(fd);
auto& conFD = *(consoleFD.get());
- rc = connect(conFD(), (struct sockaddr*)&addr, sizeof(addr));
+ rc =
+ connect(conFD(), (struct sockaddr*)&addr,
+ sizeof(addr) - sizeof(addr.sun_path) + CONSOLE_SOCKET_PATH_LEN);
if (rc < 0)
{
log<level::ERR>("Failed to connect to host console socket address",
OpenPOWER on IntegriCloud