mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-30205: Fix getsockname() for unbound AF_UNIX sockets on Linux (#1370)
* bpo-30205: Fix getsockname() for unbound AF_UNIX sockets on Linux * Add NEWS entry
This commit is contained in:
parent
b0d8203654
commit
495b5021e7
3 changed files with 9 additions and 3 deletions
|
@ -1211,9 +1211,9 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
|
|||
{
|
||||
struct sockaddr_un *a = (struct sockaddr_un *) addr;
|
||||
#ifdef __linux__
|
||||
if (a->sun_path[0] == 0) { /* Linux abstract namespace */
|
||||
addrlen -= offsetof(struct sockaddr_un, sun_path);
|
||||
return PyBytes_FromStringAndSize(a->sun_path, addrlen);
|
||||
size_t linuxaddrlen = addrlen - offsetof(struct sockaddr_un, sun_path);
|
||||
if (linuxaddrlen > 0 && a->sun_path[0] == 0) { /* Linux abstract namespace */
|
||||
return PyBytes_FromStringAndSize(a->sun_path, linuxaddrlen);
|
||||
}
|
||||
else
|
||||
#endif /* linux */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue