diff options
author | Max Kellermann <max@duempel.org> | 2015-07-22 11:01:44 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-07-22 11:05:48 +0200 |
commit | cbb595ba83b91df1bf54b2b6cfa451d37dbd0e0c (patch) | |
tree | 20fedcba5b5b01ca18459e08abccfc39b47b8f5e /src/event | |
parent | fdeec0307e4bcc841d74e994ebf767bc013a3544 (diff) | |
download | mpd-cbb595ba83b91df1bf54b2b6cfa451d37dbd0e0c.tar.gz mpd-cbb595ba83b91df1bf54b2b6cfa451d37dbd0e0c.tar.xz mpd-cbb595ba83b91df1bf54b2b6cfa451d37dbd0e0c.zip |
event/ServerSocket: use AllocatedSocketAddress to build local socket address
Diffstat (limited to 'src/event')
-rw-r--r-- | src/event/ServerSocket.cxx | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/event/ServerSocket.cxx b/src/event/ServerSocket.cxx index b1cffcfda..7e279dada 100644 --- a/src/event/ServerSocket.cxx +++ b/src/event/ServerSocket.cxx @@ -429,21 +429,12 @@ bool ServerSocket::AddPath(AllocatedPath &&path, Error &error) { #ifdef HAVE_UN - struct sockaddr_un s_un; + (void)error; - const size_t path_length = path.length(); - if (path_length >= sizeof(s_un.sun_path)) { - error.Set(server_socket_domain, - "UNIX socket path is too long"); - return false; - } - - RemoveFile(path); - - s_un.sun_family = AF_UNIX; - memcpy(s_un.sun_path, path.c_str(), path_length + 1); + AllocatedSocketAddress address; + address.SetLocal(path.c_str()); - OneServerSocket &s = AddAddress({(const sockaddr *)&s_un, sizeof(s_un)}); + OneServerSocket &s = AddAddress(std::move(address)); s.SetPath(std::move(path)); return true; |