diff options
author | Stefan Metzmacher <metze@samba.org> | 2011-03-09 11:46:34 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2011-03-09 12:27:25 +0100 |
commit | a29999392af7085a65714c92029733a1c2dfbe85 (patch) | |
tree | 37649481b8a1dcb57f7c4eec2b24f00a05a32485 /lib/socket_wrapper | |
parent | f0d59bb3cf76c5cc83638ed6ef13083fe56659b5 (diff) | |
download | samba-a29999392af7085a65714c92029733a1c2dfbe85.tar.gz samba-a29999392af7085a65714c92029733a1c2dfbe85.tar.bz2 samba-a29999392af7085a65714c92029733a1c2dfbe85.zip |
socket_wrapper: fix handling of addr and addrlen
metze
Diffstat (limited to 'lib/socket_wrapper')
-rw-r--r-- | lib/socket_wrapper/socket_wrapper.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c index cd913275f6..6eb4979d3f 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, |