summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-12-23 19:31:41 +0100
committerStefan Metzmacher <metze@samba.org>2009-12-24 17:38:04 +0100
commit4784c8c3bea98592486ca973d57c99671eb68cb2 (patch)
tree6d151806308e137e4a1c0643eb13c3a3a8a3d07d /lib
parent96207912cb4a4073849be95458a4e4e2d54bbb34 (diff)
downloadsamba-4784c8c3bea98592486ca973d57c99671eb68cb2.tar.gz
samba-4784c8c3bea98592486ca973d57c99671eb68cb2.tar.bz2
samba-4784c8c3bea98592486ca973d57c99671eb68cb2.zip
tsocket: allow AF_UNIX sockaddrs smaller than sizeof(sockaddr_un)
This is needed as getpeername() truncates the length to 2 if the peer socket has no name. metze
Diffstat (limited to 'lib')
-rw-r--r--lib/tsocket/tsocket_bsd.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c
index 1c1e58099b..22393bf02f 100644
--- a/lib/tsocket/tsocket_bsd.c
+++ b/lib/tsocket/tsocket_bsd.c
@@ -210,12 +210,13 @@ int _tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx,
struct tsocket_address *addr;
struct tsocket_address_bsd *bsda;
+ if (sa_socklen < sizeof(sa->sa_family)) {
+ errno = EINVAL;
+ return -1;
+ }
+
switch (sa->sa_family) {
case AF_UNIX:
- if (sa_socklen < sizeof(struct sockaddr_un)) {
- errno = EINVAL;
- return -1;
- }
break;
case AF_INET:
if (sa_socklen < sizeof(struct sockaddr_in)) {