summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2015-10-27 09:26:40 +0100
committerAndreas Schneider <asn@samba.org>2015-10-27 14:58:04 +0100
commitbe46c97142b9e79c45c8fdf078ac5245813738ba (patch)
treee9f0f059d1fcd2790351861beecc0770e9c50dd6 /src
parent73b2b4f16b4b5f51d4e13fba7444844e13a9f7cc (diff)
downloadsocket_wrapper-be46c97142b9e79c45c8fdf078ac5245813738ba.tar.gz
socket_wrapper-be46c97142b9e79c45c8fdf078ac5245813738ba.tar.xz
socket_wrapper-be46c97142b9e79c45c8fdf078ac5245813738ba.zip
swrap: Fix recvmsg() with UDP
This worked if the unix path was bigger than sizeof(struct sockaddr_in6). With a short unix socket pathname the buffer was to small to store the address and convert_un_in() failed. Thanks to Grigorij Demidov <grigorii.demidov@nic.cz> Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'src')
-rw-r--r--src/socket_wrapper.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 6691738..3c0c279 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -4603,6 +4603,9 @@ static ssize_t swrap_recvmsg(int s, struct msghdr *omsg, int flags)
struct swrap_address from_addr = {
.sa_socklen = sizeof(struct sockaddr_un),
};
+ struct swrap_address convert_addr = {
+ .sa_socklen = sizeof(struct sockaddr_storage),
+ };
struct socket_info *si;
struct msghdr msg;
struct iovec tmp;
@@ -4661,6 +4664,13 @@ static ssize_t swrap_recvmsg(int s, struct msghdr *omsg, int flags)
}
#endif
+ /*
+ * We convert the unix address to a IP address so we need a buffer
+ * which can store the address in case of SOCK_DGRAM, see below.
+ */
+ msg.msg_name = &convert_addr.sa;
+ msg.msg_namelen = convert_addr.sa_socklen;
+
rc = swrap_recvmsg_after(s,
si,
&msg,