Cygwin: move sun_name_t constructors into fhandler_socket_unix.cc
They are only used there anyway and it allows to use the AF_UNIX macro without tweaking header files. While at it, improve both constructors. The default constructor now creates the name of an unnamed socket, the constructor taking parameters carefully checks its input. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
a2c02d78be
commit
ae67198d55
|
@ -842,18 +842,8 @@ class sun_name_t
|
|||
/* Allows 108 bytes sun_path plus trailing NUL */
|
||||
char _nul[sizeof (struct sockaddr_un) + 1];
|
||||
};
|
||||
sun_name_t ()
|
||||
{
|
||||
un_len = 0;
|
||||
un.sun_family = 0;
|
||||
_nul[sizeof (struct sockaddr_un)] = '\0';
|
||||
}
|
||||
sun_name_t (const struct sockaddr *name, __socklen_t namelen)
|
||||
{
|
||||
un_len = namelen < (__socklen_t) sizeof un ? namelen : sizeof un;
|
||||
memcpy (&un, name, un_len);
|
||||
_nul[sizeof (struct sockaddr_un)] = '\0';
|
||||
}
|
||||
sun_name_t ();
|
||||
sun_name_t (const struct sockaddr *name, __socklen_t namelen);
|
||||
|
||||
void *operator new (size_t) __attribute__ ((nothrow))
|
||||
{ return cmalloc_abort (HEAP_FHANDLER, sizeof (sun_name_t)); }
|
||||
|
|
|
@ -69,6 +69,23 @@ GUID __cygwin_socket_guid = {
|
|||
.Data4 = { 0xba, 0xb3, 0xc5, 0xb1, 0xf9, 0x2c, 0xb8, 0x8c }
|
||||
};
|
||||
|
||||
sun_name_t::sun_name_t ()
|
||||
{
|
||||
un_len = sizeof (sa_family_t);
|
||||
un.sun_family = AF_UNIX;
|
||||
_nul[sizeof (struct sockaddr_un)] = '\0';
|
||||
}
|
||||
|
||||
sun_name_t::sun_name_t (const struct sockaddr *name, socklen_t namelen)
|
||||
{
|
||||
if (namelen < 0)
|
||||
namelen = 0;
|
||||
un_len = namelen < (__socklen_t) sizeof un ? namelen : sizeof un;
|
||||
if (name)
|
||||
memcpy (&un, name, un_len);
|
||||
_nul[sizeof (struct sockaddr_un)] = '\0';
|
||||
}
|
||||
|
||||
HANDLE
|
||||
fhandler_socket_unix::create_abstract_link (const sun_name_t *sun,
|
||||
PUNICODE_STRING pipe_name)
|
||||
|
|
Loading…
Reference in New Issue