Skip to content

Commit c6c404e

Browse files
committed
Enable use of Linux's abstract namespace for UDS.
1 parent e8d9e0b commit c6c404e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Csocket.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,9 +1302,12 @@ static bool prepare_sockaddr(struct sockaddr_un * addr, const CS_STRING & sPath)
13021302
{
13031303
memset( addr, 0, sizeof(*addr) );
13041304
addr->sun_family = AF_UNIX;
1305-
if( sizeof(addr->sun_path) <= sPath.length() )
1305+
auto length = sPath.length();
1306+
if( sizeof(addr->sun_path) <= length )
13061307
return( false );
1307-
memcpy( &addr->sun_path, sPath.c_str(), sPath.length() + 1 );
1308+
memcpy( &addr->sun_path, sPath.c_str(), length + 1 );
1309+
// Linux abstract namespace is null followed by name.
1310+
if (sPath[0] == '@') addr->sun_path = 0;
13081311
return true;
13091312
}
13101313

0 commit comments

Comments
 (0)