From 5a8ba8febbc2c62459965d4a5c91b051a9279f58 Mon Sep 17 00:00:00 2001
From: Pawel Dziepak <pdziepak@quarnos.org>
Date: Sat, 31 Aug 2013 03:19:09 +0200
Subject: [PATCH] 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.
---
src/system/kernel/fs/socket.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/system/kernel/fs/socket.cpp b/src/system/kernel/fs/socket.cpp
index 2aca987..e62ef60 100644
a
|
b
|
_user_bind(int socket, const struct sockaddr *userAddress,
|
827 | 827 | return B_BAD_VALUE; |
828 | 828 | |
829 | 829 | sockaddr_storage address; |
| 830 | memset(&address, 0, sizeof(address)); |
830 | 831 | if (!IS_USER_ADDRESS(userAddress) |
831 | 832 | || user_memcpy(&address, userAddress, addressLength) != B_OK) { |
832 | 833 | return B_BAD_ADDRESS; |
… |
… |
_user_connect(int socket, const struct sockaddr *userAddress,
|
858 | 859 | return B_BAD_VALUE; |
859 | 860 | |
860 | 861 | sockaddr_storage address; |
| 862 | memset(&address, 0, sizeof(address)); |
861 | 863 | if (!IS_USER_ADDRESS(userAddress) |
862 | 864 | || user_memcpy(&address, userAddress, addressLength) != B_OK) { |
863 | 865 | return B_BAD_ADDRESS; |