Skip to content
Snippets Groups Projects
Commit 0cc9454a authored by Leon Dietrich's avatar Leon Dietrich
Browse files

fix: unix address generation

parent abc60993
No related branches found
No related tags found
No related merge requests found
Pipeline #7704 failed
......@@ -166,7 +166,11 @@ namespace rmrf::net {
if (socket_type == socket_t::UNIX) {
sockaddr_un storage;
strncpy(storage.sun_path, interface_description.c_str(), sizeof(storage.sun_path));
std::list<socketaddr> l = {socketaddr{storage}};
// Required as the automatic initialization of sockaddr_un is broken on linux.
// This will be optimized out on platforms where it is not.
((sockaddr*) &storage)->sa_family = AF_UNIX;
const socketaddr sa{storage};
std::list<socketaddr> l = {sa};
return l;
}
......
......@@ -65,5 +65,5 @@ BOOST_AUTO_TEST_CASE(Socketaddr_comparison) {
BOOST_AUTO_TEST_CASE(Unix_socket_construction_test) {
const auto sa = get_first_general_socketaddr("/tmp/9Lq7BNBnBycd6nxy.socket", "", socket_t::UNIX);
BOOST_CHECK_EQUAL(sa.str(), "FileSocket /tmp/9Lq7BNBnBycd6nxy.socket");
BOOST_CHECK_EQUAL(sa.str(), "SocketAddress: FileSocket /tmp/9Lq7BNBnBycd6nxy.socket");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment