diff options
author | Jeremy Allison <jra@samba.org> | 2002-12-01 00:45:07 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-12-01 00:45:07 +0000 |
commit | d047db2807f8b8174cbb1cca9a835176056183cf (patch) | |
tree | c3fbcca240ed49e93db4bddca87dec475c31642b /source3 | |
parent | d5bd112906cf0d8bb47d019f4bfa8a89f63b012f (diff) | |
download | samba-d047db2807f8b8174cbb1cca9a835176056183cf.tar.gz samba-d047db2807f8b8174cbb1cca9a835176056183cf.tar.bz2 samba-d047db2807f8b8174cbb1cca9a835176056183cf.zip |
Fixup of ordered cleanup of get_dc_list - bug found by Dominik 'Aeneas' Schnitzer <dominik@schnitzer.at>
Jeremy.
(This used to be commit 15185ac437a6a0f53711bef035879173dbb492c6)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/libsmb/namequery.c | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 6190c872ee..e6fe88f203 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -1296,8 +1296,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 */ @@ -1320,13 +1319,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; @@ -1337,29 +1332,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; |