[issue25541] Wrong usage of sockaddr_un struct for abstract namespace unix sockets

anthony shaw report at bugs.python.org
Thu May 9 03:49:58 EDT 2019


anthony shaw <anthonyshaw at apache.org> added the comment:

thanks, your code example zero-pads the socket address, and looking at the socketmodule.c code it does some padding under certain circumstances.

https://github.com/python/cpython/blob/master/Modules/socketmodule.c#L1318-L1330

The Unix man page specify the same requirement you've noticed:

 When binding a socket to a pathname, a few rules should be observed
       for maximum portability and ease of coding:

       *  The pathname in sun_path should be null-terminated.

       *  The length of the pathname, including the terminating null byte,
          should not exceed the size of sun_path.

       *  The addrlen argument that describes the enclosing sockaddr_un
          structure should have a value of at least:

              offsetof(struct sockaddr_un, sun_path)+strlen(addr.sun_path)+1

          or, more simply, addrlen can be specified as sizeof(struct sock‐
          addr_un).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue25541>
_______________________________________


More information about the Python-bugs-list mailing list