agronholm / anyio

High level asynchronous concurrency and networking framework that works on top of either trio or asyncio
MIT License
1.82k stars 139 forks source link

create_unix_listener doesn't accept abstract namespace sockets #781

Closed tapetersen closed 2 months ago

tapetersen commented 2 months ago

Things to check first

AnyIO version

4.4.0

Python version

3.10

What happened?

On anyio version 3.7 at least it's possible to pass a path starting with a null byte to anyio.create_unix_listener to create an abstract unix domain socket that isn't backed by a real file and is cleaned up automatically on program close.

In version 4.4.0 (at least probably earlier) this gives a ValueError: embedded null byte when the code tries to call os.stat on the path.

How can we reproduce the bug?

import anyio
anyio.run(anyio.create_unix_listener, '\0abstract-path')

I havn't tested on trio backend or more versions but may do so later. Assuming this is something that is desired to fix I may try creating a PR for it as well.