Skip to content

Commit 6d2d0bb

Browse files
committed
Fix abstract name handling to be binary safe
Per unix(7): abstract: an abstract socket address is distinguished (from a pathname socket) by the fact that sun_path[0] is a null byte ('\0'). The socket's address in this namespace is given by the additional bytes in sun_path that are covered by the specified length of the address structure. (Null bytes in the name have no special significance.) The name has no connection with filesystem pathnames. When the address of an abstract socket is returned, the returned addrlen is greater than sizeof(sa_family_t) (i.e., greater than 2), and the name of the socket is contained in the first (addrlen - sizeof(sa_family_t)) bytes of sun_path. The existing implementation was assuming significance in null bytes contained in the abstract address identifier.
1 parent 05849a2 commit 6d2d0bb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

main/network.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ PHPAPI void php_network_populate_name_from_sockaddr(
656656

657657
if (ua->sun_path[0] == '\0') {
658658
/* abstract name */
659-
int len = strlen(ua->sun_path + 1) + 1;
659+
int len = sl - sizeof(sa_family_t);
660660
*textaddr = zend_string_init((char*)ua->sun_path, len, 0);
661661
} else {
662662
int len = strlen(ua->sun_path);

0 commit comments

Comments
 (0)