mirror of
https://github.com/python/cpython.git
synced 2025-09-30 20:31:52 +00:00
Backport bpo-30205 to 3.6 (#1403)
This commit is contained in:
parent
4dae0d111d
commit
0c2ff0898d
3 changed files with 9 additions and 3 deletions
|
@ -4660,6 +4660,10 @@ class TestUnixDomain(unittest.TestCase):
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
def testUnbound(self):
|
||||||
|
# Issue #30205
|
||||||
|
self.assertIn(self.sock.getsockname(), ('', None))
|
||||||
|
|
||||||
def testStrAddr(self):
|
def testStrAddr(self):
|
||||||
# Test binding to and retrieving a normal string pathname.
|
# Test binding to and retrieving a normal string pathname.
|
||||||
path = os.path.abspath(support.TESTFN)
|
path = os.path.abspath(support.TESTFN)
|
||||||
|
|
|
@ -36,6 +36,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- bpo-30205: Fix getsockname() for unbound AF_UNIX sockets on Linux.
|
||||||
|
|
||||||
- bpo-30070: Fixed leaks and crashes in errors handling in the parser module.
|
- bpo-30070: Fixed leaks and crashes in errors handling in the parser module.
|
||||||
|
|
||||||
- bpo-30061: Fixed crashes in IOBase methods __next__() and readlines() when
|
- bpo-30061: Fixed crashes in IOBase methods __next__() and readlines() when
|
||||||
|
|
|
@ -1212,9 +1212,9 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
|
||||||
{
|
{
|
||||||
struct sockaddr_un *a = (struct sockaddr_un *) addr;
|
struct sockaddr_un *a = (struct sockaddr_un *) addr;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
if (a->sun_path[0] == 0) { /* Linux abstract namespace */
|
size_t linuxaddrlen = addrlen - offsetof(struct sockaddr_un, sun_path);
|
||||||
addrlen -= offsetof(struct sockaddr_un, sun_path);
|
if (linuxaddrlen > 0 && a->sun_path[0] == 0) { /* Linux abstract namespace */
|
||||||
return PyBytes_FromStringAndSize(a->sun_path, addrlen);
|
return PyBytes_FromStringAndSize(a->sun_path, linuxaddrlen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* linux */
|
#endif /* linux */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue