vfs: Allow non-null-terminated UNIX socket pathnames

This patch fix one of the compatibility issues mentioned in #3255. It
allows applications to call bind() or connect() passing an sockaddr_un
structure with a pathname that is not null-terminated.

Some systems did not require pathname in sockaddr_un::sun_path to be
null-terminated, instead the end of the string is determined by the size
of the structure passed as an argument of bind() or connect().

The standard is a bit vague in this matter but suggest that the path
should be null-terminated and the functions bind() and connect() should
be given sizeof(sockaddr_un) as a structure size.
This commit is contained in:
Pawel Dziepak 2013-08-31 03:19:09 +02:00
parent d691c48ca6
commit 35cc5c9897

View File

@ -827,6 +827,7 @@ _user_bind(int socket, const struct sockaddr *userAddress,
return B_BAD_VALUE;
sockaddr_storage address;
memset(&address, 0, sizeof(address));
if (!IS_USER_ADDRESS(userAddress)
|| user_memcpy(&address, userAddress, addressLength) != B_OK) {
return B_BAD_ADDRESS;
@ -858,6 +859,7 @@ _user_connect(int socket, const struct sockaddr *userAddress,
return B_BAD_VALUE;
sockaddr_storage address;
memset(&address, 0, sizeof(address));
if (!IS_USER_ADDRESS(userAddress)
|| user_memcpy(&address, userAddress, addressLength) != B_OK) {
return B_BAD_ADDRESS;