Backport bpo-30205 to 3.6 (#1403)

This commit is contained in:
Antoine Pitrou 2017-05-03 00:14:29 +02:00 committed by GitHub
parent 4dae0d111d
commit 0c2ff0898d
3 changed files with 9 additions and 3 deletions

View file

@ -1212,9 +1212,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 */