anthony shaw <anthonys...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue25541>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to