diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-07-26 10:07:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-26 10:07:41 (GMT) |
commit | cd0a59f1fa32fc1e4730c52c761f4d0190833587 (patch) | |
tree | 3aff1299eb2d838208cbf024bf49895ae2657b18 /Misc | |
parent | eff4aa5409a0dfe6ccd5ef4662578c77ee2954f1 (diff) | |
download | cpython-cd0a59f1fa32fc1e4730c52c761f4d0190833587.zip cpython-cd0a59f1fa32fc1e4730c52c761f4d0190833587.tar.gz cpython-cd0a59f1fa32fc1e4730c52c761f4d0190833587.tar.bz2 |
gh-94821: Fix autobind of empty unix domain address (GH-94826) (GH-94875)
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 'Misc')
-rw-r--r-- | Misc/NEWS.d/next/Library/2022-07-14-00-43-52.gh-issue-94821.e17ghU.rst | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2022-07-14-00-43-52.gh-issue-94821.e17ghU.rst b/Misc/NEWS.d/next/Library/2022-07-14-00-43-52.gh-issue-94821.e17ghU.rst new file mode 100644 index 0000000..bf7885a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-07-14-00-43-52.gh-issue-94821.e17ghU.rst @@ -0,0 +1,2 @@ +Fix binding of unix socket to empty address on Linux to use an available +address from the abstract namespace, instead of "\0". |