diff options
author | Stefan Metzmacher <metze@samba.org> | 2011-10-21 09:49:30 +0200 |
---|---|---|
committer | Matthieu Patou <mat@samba.org> | 2011-10-21 22:29:09 +0200 |
commit | 66530e91498cfa77a9d2e3a031f8a2e1c5ee6804 (patch) | |
tree | ecb036ac33dddbaae1373d7f3acddd75c12e6b8e /libcli/cldap | |
parent | e38d97e0424f7e5b21c8b7ac0b1f1bac33f19d69 (diff) | |
download | samba-66530e91498cfa77a9d2e3a031f8a2e1c5ee6804.tar.gz |
libcli/cldap: make sure the local and remote address family matches
metze
Signed-off-by: Matthieu Patou <mat@matws.net>
Diffstat (limited to 'libcli/cldap')
-rw-r--r-- | libcli/cldap/cldap.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/libcli/cldap/cldap.c b/libcli/cldap/cldap.c index 219b343d806..8d7cbb0408b 100644 --- a/libcli/cldap/cldap.c +++ b/libcli/cldap/cldap.c @@ -312,6 +312,27 @@ NTSTATUS cldap_socket_init(TALLOC_CTX *mem_ctx, struct tsocket_address *any = NULL; NTSTATUS status; int ret; + const char *fam = NULL; + + if (local_addr == NULL && remote_addr == NULL) { + return NT_STATUS_INVALID_PARAMETER_MIX; + } + + if (remote_addr) { + bool is_ipv4; + bool is_ipv6; + + is_ipv4 = tsocket_address_is_inet(remote_addr, "ipv4"); + is_ipv6 = tsocket_address_is_inet(remote_addr, "ipv6"); + + if (is_ipv4) { + fam = "ipv4"; + } else if (is_ipv6) { + fam = "ipv6"; + } else { + return NT_STATUS_INVALID_ADDRESS; + } + } c = talloc_zero(mem_ctx, struct cldap_socket); if (!c) { @@ -319,11 +340,10 @@ NTSTATUS cldap_socket_init(TALLOC_CTX *mem_ctx, } if (!local_addr) { - /* we use ipv4 here instead of ip, as otherwise we end - up with a PF_INET6 socket, and sendto() for ipv4 - addresses will fail. That breaks cldap name - resolution for winbind to IPv4 hosts. */ - ret = tsocket_address_inet_from_strings(c, "ipv4", + /* + * Here we the address family of the remote address. + */ + ret = tsocket_address_inet_from_strings(c, fam, NULL, 0, &any); if (ret != 0) { |