Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c2ff08

Browse files
authored
Backportbpo-30205 to 3.6 (#1403)
1 parent4dae0d1 commit0c2ff08

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

‎Lib/test/test_socket.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4660,6 +4660,10 @@ def bind(self, sock, path):
46604660
else:
46614661
raise
46624662

4663+
deftestUnbound(self):
4664+
# Issue #30205
4665+
self.assertIn(self.sock.getsockname(), ('',None))
4666+
46634667
deftestStrAddr(self):
46644668
# Test binding to and retrieving a normal string pathname.
46654669
path=os.path.abspath(support.TESTFN)

‎Misc/NEWS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Core and Builtins
3636
Library
3737
-------
3838

39+
- bpo-30205: Fix getsockname() for unbound AF_UNIX sockets on Linux.
40+
3941
- bpo-30070: Fixed leaks and crashes in errors handling in the parser module.
4042

4143
- bpo-30061: Fixed crashes in IOBase methods __next__() and readlines() when

‎Modules/socketmodule.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,9 +1212,9 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
12121212
{
12131213
structsockaddr_un*a= (structsockaddr_un*)addr;
12141214
#ifdef__linux__
1215-
if (a->sun_path[0]==0) {/* Linux abstract namespace */
1216-
addrlen-= offsetof(structsockaddr_un,sun_path);
1217-
returnPyBytes_FromStringAndSize(a->sun_path,addrlen);
1215+
size_tlinuxaddrlen=addrlen- offsetof(structsockaddr_un,sun_path);
1216+
if (linuxaddrlen>0&&a->sun_path[0]==0) {/* Linux abstract namespace */
1217+
returnPyBytes_FromStringAndSize(a->sun_path,linuxaddrlen);
12181218
}
12191219
else
12201220
#endif/* linux */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp