diff options
author | Stefan Metzmacher <metze@samba.org> | 2009-12-23 19:34:32 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2009-12-24 17:38:29 +0100 |
commit | 17c804a67593cdb4d8646b5be6b50fddf56b3e27 (patch) | |
tree | 9556c9d685357415e1473626765f2f3388ccce58 /lib | |
parent | 4784c8c3bea98592486ca973d57c99671eb68cb2 (diff) | |
download | samba-17c804a67593cdb4d8646b5be6b50fddf56b3e27.tar.gz samba-17c804a67593cdb4d8646b5be6b50fddf56b3e27.tar.bz2 samba-17c804a67593cdb4d8646b5be6b50fddf56b3e27.zip |
tsocket: only copy the specific part of sockaddr*
This makes sure we fill the unspefic bytes with 0
and have zero termination for sockaddr_un.
metze
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tsocket/tsocket_bsd.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c index 22393bf02f..7c0255742c 100644 --- a/lib/tsocket/tsocket_bsd.c +++ b/lib/tsocket/tsocket_bsd.c @@ -217,12 +217,16 @@ int _tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx, switch (sa->sa_family) { case AF_UNIX: + if (sa_socklen > sizeof(struct sockaddr_un)) { + sa_socklen = sizeof(struct sockaddr_un); + } break; case AF_INET: if (sa_socklen < sizeof(struct sockaddr_in)) { errno = EINVAL; return -1; } + sa_socklen = sizeof(struct sockaddr_in); break; #ifdef HAVE_IPV6 case AF_INET6: @@ -230,6 +234,7 @@ int _tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx, errno = EINVAL; return -1; } + sa_socklen = sizeof(struct sockaddr_in6); break; #endif default: |