summaryrefslogtreecommitdiff
path: root/lib/socket_wrapper
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-03-09 11:46:34 +0100
committerGünther Deschner <gd@samba.org>2011-03-09 12:27:25 +0100
commita29999392af7085a65714c92029733a1c2dfbe85 (patch)
tree37649481b8a1dcb57f7c4eec2b24f00a05a32485 /lib/socket_wrapper
parentf0d59bb3cf76c5cc83638ed6ef13083fe56659b5 (diff)
downloadsamba-a29999392af7085a65714c92029733a1c2dfbe85.tar.gz
socket_wrapper: fix handling of addr and addrlen
metze
Diffstat (limited to 'lib/socket_wrapper')
-rw-r--r--lib/socket_wrapper/socket_wrapper.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c
index cd913275f63..6eb4979d3fc 100644
--- a/lib/socket_wrapper/socket_wrapper.c
+++ b/lib/socket_wrapper/socket_wrapper.c
@@ -1538,10 +1538,11 @@ _PUBLIC_ int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
child_si->peername = sockaddr_dup(my_addr, len);
if (addr != NULL && addrlen != NULL) {
- *addrlen = len;
- if (*addrlen >= len)
- memcpy(addr, my_addr, len);
- *addrlen = 0;
+ size_t copy_len = MIN(*addrlen, len);
+ if (copy_len > 0) {
+ memcpy(addr, my_addr, copy_len);
+ }
+ *addrlen = len;
}
ret = real_getsockname(fd, (struct sockaddr *)(void *)&un_my_addr,