mirror of
https://github.com/samba-team/samba.git
synced 2025-03-05 20:58:40 +03:00
s3: libsmb: Make discover_dc_netbios() use internal_resolve_name_talloc().
No more external users of internal_resolve_name(). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Noel Power <npower@samba.org>
This commit is contained in:
parent
fed4b6341c
commit
a16d023c15
@ -444,9 +444,9 @@ static NTSTATUS discover_dc_netbios(TALLOC_CTX *mem_ctx,
|
|||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
enum nbt_name_type name_type = NBT_NAME_LOGON;
|
enum nbt_name_type name_type = NBT_NAME_LOGON;
|
||||||
struct ip_service *iplist = NULL;
|
struct ip_service *iplist = NULL;
|
||||||
int i;
|
size_t i;
|
||||||
struct ip_service_name *dclist = NULL;
|
struct ip_service_name *dclist = NULL;
|
||||||
int count;
|
size_t count;
|
||||||
static const char *resolve_order[] = { "lmhosts", "wins", "bcast", NULL };
|
static const char *resolve_order[] = { "lmhosts", "wins", "bcast", NULL };
|
||||||
|
|
||||||
*returned_dclist = NULL;
|
*returned_dclist = NULL;
|
||||||
@ -456,9 +456,13 @@ static NTSTATUS discover_dc_netbios(TALLOC_CTX *mem_ctx,
|
|||||||
name_type = NBT_NAME_PDC;
|
name_type = NBT_NAME_PDC;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = internal_resolve_name(domain_name, name_type, NULL,
|
status = internal_resolve_name_talloc(mem_ctx,
|
||||||
&iplist, &count,
|
domain_name,
|
||||||
resolve_order);
|
name_type,
|
||||||
|
NULL,
|
||||||
|
&iplist,
|
||||||
|
&count,
|
||||||
|
resolve_order);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DEBUG(10,("discover_dc_netbios: failed to find DC\n"));
|
DEBUG(10,("discover_dc_netbios: failed to find DC\n"));
|
||||||
return status;
|
return status;
|
||||||
@ -466,7 +470,7 @@ static NTSTATUS discover_dc_netbios(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
dclist = talloc_zero_array(mem_ctx, struct ip_service_name, count);
|
dclist = talloc_zero_array(mem_ctx, struct ip_service_name, count);
|
||||||
if (!dclist) {
|
if (!dclist) {
|
||||||
SAFE_FREE(iplist);
|
TALLOC_FREE(iplist);
|
||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,13 +484,13 @@ static NTSTATUS discover_dc_netbios(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
ok = sockaddr_storage_to_samba_sockaddr(&r->sa, &iplist[i].ss);
|
ok = sockaddr_storage_to_samba_sockaddr(&r->sa, &iplist[i].ss);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
SAFE_FREE(iplist);
|
TALLOC_FREE(iplist);
|
||||||
TALLOC_FREE(dclist);
|
TALLOC_FREE(dclist);
|
||||||
return NT_STATUS_INVALID_PARAMETER;
|
return NT_STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
r->hostname = talloc_strdup(mem_ctx, addr);
|
r->hostname = talloc_strdup(mem_ctx, addr);
|
||||||
if (!r->hostname) {
|
if (!r->hostname) {
|
||||||
SAFE_FREE(iplist);
|
TALLOC_FREE(iplist);
|
||||||
TALLOC_FREE(dclist);
|
TALLOC_FREE(dclist);
|
||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
@ -495,7 +499,15 @@ static NTSTATUS discover_dc_netbios(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
*returned_dclist = dclist;
|
*returned_dclist = dclist;
|
||||||
*returned_count = count;
|
*returned_count = count;
|
||||||
SAFE_FREE(iplist);
|
TALLOC_FREE(iplist);
|
||||||
|
|
||||||
|
/* Paranoia in casting size_t -> int. */
|
||||||
|
if (*returned_count < 0) {
|
||||||
|
TALLOC_FREE(dclist);
|
||||||
|
*returned_dclist = NULL;
|
||||||
|
*returned_count = 0;
|
||||||
|
return NT_STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user