diff options
author | Stefan Metzmacher <metze@samba.org> | 2009-12-23 19:31:41 +0100 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2010-05-17 09:50:19 +0200 |
commit | 18717cad039d251ff9b3c4813f6e67911e0ebebc (patch) | |
tree | cb158c35431347b90314436289c69ec1fdb41982 | |
parent | 2975e65e505c1d3c166bc1ee4be2f20a180086eb (diff) | |
download | samba-18717cad039d251ff9b3c4813f6e67911e0ebebc.tar.gz |
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
(cherry picked from commit 4784c8c3bea98592486ca973d57c99671eb68cb2)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit e9f7d271e2a96d5dbce63bc454c68930cbc52d62)
-rw-r--r-- | lib/tsocket/tsocket_bsd.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c index 201788e9223..6f6b4229f9f 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)) { |