summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2012-04-30 16:16:39 -0700
committerKarolin Seeger <kseeger@samba.org>2012-06-30 13:43:38 +0200
commit6d200f4342ce074bbf66ae4e247fcadb95620cf7 (patch)
tree916175aa48561ce17b37f12a26371211a5e5f68d
parentfd3ad537976f2633a6e91dcc2a596c12e7b5f400 (diff)
downloadsamba-6d200f4342ce074bbf66ae4e247fcadb95620cf7.tar.gz
Fix remove_duplicate_addrs2 to do exactly what it says. Previously it could leave zero addresses in the list.
(cherry picked from commit 8e9db61b447d22bad84a8c9ae450a71d9c3e6d58)
-rw-r--r--source3/libsmb/namequery.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 858330db2ac..ff43706175f 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -571,7 +571,7 @@ static int remove_duplicate_addrs2(struct ip_service *iplist, int count )
DEBUG(10,("remove_duplicate_addrs2: "
"looking for duplicate address/port pairs\n"));
- /* one loop to remove duplicates */
+ /* One loop to set duplicates to a zero addr. */
for ( i=0; i<count; i++ ) {
if ( is_zero_addr((struct sockaddr *)&iplist[i].ss)) {
continue;
@@ -585,18 +585,17 @@ static int remove_duplicate_addrs2(struct ip_service *iplist, int count )
}
}
- /* one loop to clean up any holes we left */
- /* first ip should never be a zero_ip() */
- for (i = 0; i<count; ) {
- if (is_zero_addr((struct sockaddr *)&iplist[i].ss) ) {
- if (i != count-1) {
- memmove(&iplist[i], &iplist[i+1],
- (count - i - 1)*sizeof(iplist[i]));
+ /* Now remove any addresses set to zero above. */
+ for (i = 0; i < count; i++) {
+ while (i < count &&
+ is_zero_addr((struct sockaddr *)&iplist[i].ss)) {
+ if (count-i-1>0) {
+ memmove(&iplist[i],
+ &iplist[i+1],
+ (count-i-1)*sizeof(struct ip_service));
}
count--;
- continue;
}
- i++;
}
return count;