Commit be46c971 authored by Andreas Schneider's avatar Andreas Schneider

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: default avatarAndreas Schneider <asn@samba.org>
Reviewed-by: default avatarStefan Metzmacher <metze@samba.org>
parent 73b2b4f1
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment