summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-11-05 09:43:05 +0100
committerStefan Metzmacher <metze@samba.org>2010-11-05 14:40:00 +0000
commitc1e3c8b550e10199ad29983cc759f6e259cac613 (patch)
tree3fe918dbd25763f7c2fd96b33515b0e729e76306
parent11ae1046a00d858551692d9bd05935d16734a2ef (diff)
downloadsamba-c1e3c8b550e10199ad29983cc759f6e259cac613.tar.gz
samba-c1e3c8b550e10199ad29983cc759f6e259cac613.tar.bz2
samba-c1e3c8b550e10199ad29983cc759f6e259cac613.zip
socket_wrapper: fill in sa.sa_len if the system supports it
metze Autobuild-User: Stefan Metzmacher <metze@samba.org> Autobuild-Date: Fri Nov 5 14:40:00 UTC 2010 on sn-devel-104
-rw-r--r--lib/socket_wrapper/socket_wrapper.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c
index c52d98cf91..2985d007ec 100644
--- a/lib/socket_wrapper/socket_wrapper.c
+++ b/lib/socket_wrapper/socket_wrapper.c
@@ -584,10 +584,14 @@ static struct socket_info *find_socket_info(int fd)
static int sockaddr_convert_to_un(struct socket_info *si, const struct sockaddr *in_addr, socklen_t in_len,
struct sockaddr_un *out_addr, int alloc_sock, int *bcast)
{
+ struct sockaddr *out = (struct sockaddr *)(void *)out_addr;
if (!out_addr)
return 0;
- out_addr->sun_family = AF_UNIX;
+ out->sa_family = AF_UNIX;
+#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
+ out->sa_len = sizeof(*out_addr);
+#endif
switch (in_addr->sa_family) {
case AF_INET:
@@ -622,6 +626,8 @@ static int sockaddr_convert_from_un(const struct socket_info *si,
struct sockaddr *out_addr,
socklen_t *out_addrlen)
{
+ int ret;
+
if (out_addr == NULL || out_addrlen == NULL)
return 0;
@@ -643,7 +649,11 @@ static int sockaddr_convert_from_un(const struct socket_info *si,
errno = ESOCKTNOSUPPORT;
return -1;
}
- return convert_un_in(in_addr, out_addr, out_addrlen);
+ ret = convert_un_in(in_addr, out_addr, out_addrlen);
+#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
+ out_addr->sa_len = *out_addrlen;
+#endif
+ return ret;
default:
break;
}