patch 1754489 by vlahan:
improve portability of address length calculation for AF_UNIX sockets
This commit is contained in:
parent
501dbbfb70
commit
964ca4274f
|
@ -1001,7 +1001,7 @@ makesockaddr(int sockfd, struct sockaddr *addr, int addrlen, int proto)
|
|||
struct sockaddr_un *a = (struct sockaddr_un *) addr;
|
||||
#ifdef linux
|
||||
if (a->sun_path[0] == 0) { /* Linux abstract namespace */
|
||||
addrlen -= (sizeof(*a) - sizeof(a->sun_path));
|
||||
addrlen -= offsetof(struct sockaddr_un, sun_path);
|
||||
return PyString_FromStringAndSize(a->sun_path,
|
||||
addrlen);
|
||||
}
|
||||
|
@ -1207,7 +1207,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
|
|||
#if defined(PYOS_OS2)
|
||||
*len_ret = sizeof(*addr);
|
||||
#else
|
||||
*len_ret = len + sizeof(*addr) - sizeof(addr->sun_path);
|
||||
*len_ret = len + offsetof(struct sockaddr_un, sun_path);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue