diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-07-17 15:39:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-17 15:39:30 (GMT) |
commit | 5d75edd925f4e0624bd341b7c3ec8c61f0deec23 (patch) | |
tree | a7ce29f5ee6e9123070359bb554e104b6b72a801 /Lib/test/test_source_encoding.py | |
parent | 31608abf55839f5fa9cce33d530e35ea6e0ad427 (diff) | |
download | cpython-5d75edd925f4e0624bd341b7c3ec8c61f0deec23.zip cpython-5d75edd925f4e0624bd341b7c3ec8c61f0deec23.tar.gz cpython-5d75edd925f4e0624bd341b7c3ec8c61f0deec23.tar.bz2 |
gh-94821: Fix autobind of empty unix domain address (GH-94826)
When binding a unix socket to an empty address on Linux, the socket is
automatically bound to an available address in the abstract namespace.
>>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
>>> s.bind("")
>>> s.getsockname()
b'\x0075499'
Since python 3.9, the socket is bound to the one address:
>>> s.getsockname()
b'\x00'
And trying to bind multiple sockets will fail with:
Traceback (most recent call last):
File "/home/nsoffer/src/cpython/Lib/test/test_socket.py", line 5553, in testAutobind
s2.bind("")
OSError: [Errno 98] Address already in use
Added 2 tests:
- Auto binding empty address on Linux
- Failing to bind an empty address on other platforms
Fixes f6b3a07b7df6 (bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866)
(cherry picked from commit c22f134211743cd5ad14cec1dd4f527bee542b4c)
Co-authored-by: Nir Soffer <nsoffer@redhat.com>
Diffstat (limited to 'Lib/test/test_source_encoding.py')
0 files changed, 0 insertions, 0 deletions