summaryrefslogtreecommitdiff
path: root/source4/lib/socket_wrapper
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-12-05 15:22:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:05 -0500
commitc53a5c4f3e17496fa944c80cf911f8780de7ae67 (patch)
treeea052c5e5fadede17faebc4a60c886c5086092d1 /source4/lib/socket_wrapper
parent7dbe0e3199f9bd5c2cea1ae89e3929798f3b24c2 (diff)
downloadsamba-c53a5c4f3e17496fa944c80cf911f8780de7ae67.tar.gz
samba-c53a5c4f3e17496fa944c80cf911f8780de7ae67.tar.bz2
samba-c53a5c4f3e17496fa944c80cf911f8780de7ae67.zip
r12073: fix vlgrind error, calculate the correct size for memcpy()
and don't assume out_len is >= sizeof(*in_addr) metze (This used to be commit 61dbe9e5070085117b12b5b37cf0e7fe4342e2a3)
Diffstat (limited to 'source4/lib/socket_wrapper')
-rw-r--r--source4/lib/socket_wrapper/socket_wrapper.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/source4/lib/socket_wrapper/socket_wrapper.c b/source4/lib/socket_wrapper/socket_wrapper.c
index d9f61f7e3c..d517a4c1b5 100644
--- a/source4/lib/socket_wrapper/socket_wrapper.c
+++ b/source4/lib/socket_wrapper/socket_wrapper.c
@@ -357,16 +357,23 @@ static int sockaddr_convert_from_un(const struct socket_info *si,
socklen_t un_addrlen,
int family,
struct sockaddr *out_addr,
- socklen_t *out_len)
+ socklen_t *_out_addrlen)
{
- if (out_addr == NULL || out_len == NULL)
+ socklen_t out_addrlen;
+
+ if (out_addr == NULL || _out_addrlen == NULL)
return 0;
if (un_addrlen == 0) {
- *out_len = 0;
+ *_out_addrlen = 0;
return 0;
}
+ out_addrlen = *_out_addrlen;
+ if (out_addrlen > un_addrlen) {
+ out_addrlen = un_addrlen;
+ }
+
switch (family) {
case AF_INET:
switch (si->type) {
@@ -377,10 +384,10 @@ static int sockaddr_convert_from_un(const struct socket_info *si,
errno = ESOCKTNOSUPPORT;
return -1;
}
- return convert_un_in(in_addr, (struct sockaddr_in *)out_addr, out_len);
+ return convert_un_in(in_addr, (struct sockaddr_in *)out_addr, _out_addrlen);
case AF_UNIX:
- memcpy(out_addr, in_addr, sizeof(*in_addr));
- *out_len = sizeof(*in_addr);
+ memcpy(out_addr, in_addr, out_addrlen);
+ *_out_addrlen = out_addrlen;
return 0;
default:
break;