summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2012-04-27 16:02:15 -0700
committerJeremy Allison <jra@samba.org>2012-04-30 09:26:37 -0700
commit01e884675e3d1cffb0149108225fbd21c3a73f4e (patch)
treed3d2583847f8d49e37950dcf6b43d8704bf78af1 /source3
parent9126f33a57479afdf23e5c4d2f4de4854d53b636 (diff)
downloadsamba-01e884675e3d1cffb0149108225fbd21c3a73f4e.tar.gz
samba-01e884675e3d1cffb0149108225fbd21c3a73f4e.tar.bz2
samba-01e884675e3d1cffb0149108225fbd21c3a73f4e.zip
Fix remove_duplicate_addrs2 to do exactly what it says. Previously it could leave zero addresses in the list.
Diffstat (limited to 'source3')
-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 a604f05d81..0f2c66f32a 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -1109,7 +1109,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(&iplist[i].ss)) {
continue;
@@ -1124,18 +1124,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(&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(&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;