Skip to content

[3.10] gh-94821: Fix autobind of empty unix domain address (GH-94826) - #94874

Merged
miss-islington merged 1 commit into
python:3.10from
miss-islington:backport-c22f134-3.10
Jul 17, 2022
Merged

[3.10] gh-94821: Fix autobind of empty unix domain address (GH-94826)#94874
miss-islington merged 1 commit into
python:3.10from
miss-islington:backport-c22f134-3.10

Conversation

@miss-islington

@miss-islingtonmiss-islington commented Jul 15, 2022

Copy link
Copy Markdown
Contributor

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 f6b3a07 (bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866)
(cherry picked from commit c22f134)

Co-authored-by: Nir Soffer nsoffer@redhat.com

…4826)
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 f6b3a07 (bpo-44493: Add missing terminated NUL in sockaddr_un's length (pythonGH-26866)
(cherry picked from commit c22f134)
Co-authored-by: Nir Soffer <nsoffer@redhat.com>
@miss-islington

Copy link
Copy Markdown
ContributorAuthor

Status check is done, and it's a success ✅ .

2 similar comments
@miss-islington

Copy link
Copy Markdown
ContributorAuthor

Status check is done, and it's a success ✅ .

@miss-islington

Copy link
Copy Markdown
ContributorAuthor

Status check is done, and it's a success ✅ .

@miss-islington
miss-islington merged commit 5d75edd into python:3.10Jul 17, 2022
@miss-islington
miss-islington deleted the backport-c22f134-3.10 branch July 17, 2022 15:39
@serhiy-storchakaserhiy-storchaka removed their assignment Sep 8, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bugAn unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@miss-islington@serhiy-storchaka@bedevere-bot@nirs