static NTSTATUS get_dc_list(const char *domain,
const char *sitename,
struct ip_service **ip_list,
- int *count,
+ size_t *ret_count,
enum dc_lookup_type lookup_type,
bool *ordered)
{
int auto_name_type = 0x1C;
*ip_list = NULL;
- *count = 0;
+ *ret_count = 0;
*ordered = False;
if (!NT_STATUS_IS_OK(status)) {
continue;
}
+ /* Paranoia. */
+ if (auto_count < 0) {
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto out;
+ }
+ /* Wrap check. */
+ if (num_addresses + auto_count < num_addresses) {
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto out;
+ }
num_addresses += auto_count;
DEBUG(8,("Adding %d DC's from auto lookup\n",
auto_count));
} else {
+ /* Wrap check. */
+ if (num_addresses + 1 < num_addresses) {
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto out;
+ }
num_addresses++;
}
}
just return the list of DC's. Or maybe we just failed. */
if (num_addresses == 0) {
+ int tmp_count = 0;
if (done_auto_lookup) {
DEBUG(4,("get_dc_list: no servers found\n"));
status = NT_STATUS_NO_LOGON_SERVERS;
}
status = internal_resolve_name(domain, auto_name_type,
sitename, ip_list,
- count, resolve_order);
+ &tmp_count, resolve_order);
+ /* Paranoia. */
+ if (tmp_count < 0) {
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto out;
+ }
+ if (NT_STATUS_IS_OK(status)) {
+ *ret_count = (size_t)tmp_count;
+ }
goto out;
}
}
*ip_list = return_iplist;
- *count = local_count;
+ *ret_count = local_count;
- status = ( *count != 0 ? NT_STATUS_OK : NT_STATUS_NO_LOGON_SERVERS );
+ status = (*ret_count != 0 ? NT_STATUS_OK : NT_STATUS_NO_LOGON_SERVERS);
out:
if (!NT_STATUS_IS_OK(status)) {
SAFE_FREE(return_iplist);
*ip_list = NULL;
- *count = 0;
+ *ret_count = 0;
}
SAFE_FREE(auto_ip_list);
enum dc_lookup_type lookup_type = DC_NORMAL_LOOKUP;
struct ip_service *ip_list_malloc = NULL;
struct ip_service *ip_list = NULL;
- int count = 0;
+ size_t count = 0;
DBG_INFO("attempting lookup for name %s (sitename %s)\n",
domain,
goto out;
}
- /* Paranoia check. */
- if (count < 0) {
- status = NT_STATUS_INVALID_PARAMETER;
- goto out;
- }
-
/* only sort if we don't already have an ordered list */
if (!ordered) {
sort_service_list(ip_list_malloc, count);
status = dup_ip_service_array(ctx,
&ip_list,
ip_list_malloc,
- (size_t)count);
+ count);
if (!NT_STATUS_IS_OK(status)) {
goto out;
}
- *ret_count = (size_t)count;
+ *ret_count = count;
*ip_list_ret = ip_list;
out:
struct ip_service **ip_list_ret,
size_t *ret_count)
{
- int count = 0;
+ size_t count = 0;
struct ip_service *ip_list_malloc = NULL;
struct ip_service *ip_list = NULL;
bool ordered = false;
goto out;
}
- /* Paranoia check. */
- if (count < 0) {
- status = NT_STATUS_INVALID_PARAMETER;
- goto out;
- }
-
/* only sort if we don't already have an ordered list */
if (!ordered ) {
sort_service_list(ip_list_malloc, count);
status = dup_ip_service_array(ctx,
&ip_list,
ip_list_malloc,
- (size_t)count);
+ count);
if (!NT_STATUS_IS_OK(status)) {
goto out;
}
- *ret_count = (size_t)count;
+ *ret_count = count;
*ip_list_ret = ip_list;
out: