mirror of
https://github.com/samba-team/samba.git
synced 2025-02-19 21:57:57 +03:00
Fixup of ordered cleanup of get_dc_list - bug found by Dominik 'Aeneas' Schnitzer <dominik@schnitzer.at>
Jeremy. (This used to be commit 7ba051a830a7dc96e3860a87643a3ac99cdf5836)
This commit is contained in:
parent
899582f0f1
commit
fe768c3315
@ -1294,8 +1294,7 @@ BOOL get_dc_list(const char *domain, struct in_addr **ip_list, int *count, int *
|
||||
|
||||
/* fill in the return list now with real IP's */
|
||||
|
||||
while ( (local_count<num_addresses) && next_token(&p,name,LIST_SEP,sizeof(name)) )
|
||||
{
|
||||
while ( (local_count<num_addresses) && next_token(&p,name,LIST_SEP,sizeof(name)) ) {
|
||||
struct in_addr name_ip;
|
||||
|
||||
/* copy any addersses from the auto lookup */
|
||||
@ -1318,13 +1317,9 @@ BOOL get_dc_list(const char *domain, struct in_addr **ip_list, int *count, int *
|
||||
/* need to remove duplicates in the list if we have
|
||||
any explicit password servers */
|
||||
|
||||
if ( *ordered )
|
||||
{
|
||||
int hole_index = -1;
|
||||
|
||||
if ( *ordered ) {
|
||||
/* one loop to remove duplicates */
|
||||
for ( i=0; i<local_count; i++ )
|
||||
{
|
||||
for ( i=0; i<local_count; i++ ) {
|
||||
if ( is_zero_ip(return_iplist[i]) )
|
||||
continue;
|
||||
|
||||
@ -1335,29 +1330,17 @@ BOOL get_dc_list(const char *domain, struct in_addr **ip_list, int *count, int *
|
||||
}
|
||||
|
||||
/* one loop to clean up any holes we left */
|
||||
/* first ip can never be a zero_ip() */
|
||||
i = 0;
|
||||
while ( i<local_count )
|
||||
{
|
||||
if ( !is_zero_ip(return_iplist[i]) ) {
|
||||
i++;
|
||||
/* first ip should never be a zero_ip() */
|
||||
for (i = 0; i<local_count; ) {
|
||||
if ( is_zero_ip(return_iplist[i]) ) {
|
||||
if (i != local_count-1 )
|
||||
memmove(&return_iplist[i], &return_iplist[i+1],
|
||||
(local_count - i - 1)*sizeof(return_iplist[i]));
|
||||
local_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
hole_index = i;
|
||||
i++;
|
||||
|
||||
while ( i<local_count ) {
|
||||
if ( !is_zero_ip(return_iplist[i]) )
|
||||
return_iplist[hole_index++] = return_iplist[i];
|
||||
i++;
|
||||
}
|
||||
|
||||
/* we should exit the loop implicitly here, but ... */
|
||||
break;
|
||||
}
|
||||
|
||||
local_count = hole_index;
|
||||
}
|
||||
|
||||
*ip_list = return_iplist;
|
||||
|
Loading…
x
Reference in New Issue
Block a user