summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-12-01 00:46:50 +0000
committerJeremy Allison <jra@samba.org>2002-12-01 00:46:50 +0000
commitfe768c331533898989ae422d0b42a3ef9af3262e (patch)
tree4dc0512dc42c46507d2377ad58b4f500825b17f0
parent899582f0f17d58a51d12717001224c2b066ae46f (diff)
downloadsamba-fe768c331533898989ae422d0b42a3ef9af3262e.tar.gz
samba-fe768c331533898989ae422d0b42a3ef9af3262e.tar.bz2
samba-fe768c331533898989ae422d0b42a3ef9af3262e.zip
Fixup of ordered cleanup of get_dc_list - bug found by Dominik 'Aeneas' Schnitzer <dominik@schnitzer.at>
Jeremy. (This used to be commit 7ba051a830a7dc96e3860a87643a3ac99cdf5836)
-rw-r--r--source3/libsmb/namequery.c37
1 files changed, 10 insertions, 27 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 1c5af8bff0..6a59b73db2 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -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;