bug in resolve_ads()
tridge at samba.org
tridge at samba.org
Tue Jul 18 04:36:04 GMT 2006
Jerry,
Just noticed a bug in resolve_ads() in samba_3_0 branch - it has a big
comment with your name on it which is why I thought of you :-)
The loop starting with:
while ( i < numdcs ) {
will loop forever chewing lots of CPU if there is a DC listed in the
reply from ads_dns_query_dcs() which doesn't resolve via DNS. In my
case I have a DC which has been removed from the domain called
"vnet3-dc2.vnet3.tridgell.net". The main w2k3 DC is still listing it
as a DC, but has removed it from DNS (DNS is also hosted on the w2k3
box). Arguably this is a w2k3 bug, but I think we need to handle it a
bit more gracefully than spinning forever :)
Patch below.
Cheers, Tridge
Index: libsmb/namequery.c
===================================================================
--- libsmb/namequery.c (revision 17105)
+++ libsmb/namequery.c (working copy)
@@ -1051,16 +1051,18 @@
return False;
}
- i = 0;
- while ( i < numdcs ) {
+ *return_count = 0;
+ for (i=0;i<numdcs;i++) {
+ struct ip_service *r = &(*return_iplist)[*return_count];
+
/* use the IP address from the SRV structure if we have one */
if ( is_zero_ip( dcs[i].ip ) )
- (*return_iplist)[i].ip = *interpret_addr2(dcs[i].hostname);
+ r->ip = *interpret_addr2(dcs[i].hostname);
else
- (*return_iplist)[i].ip = dcs[i].ip;
+ r->ip = dcs[i].ip;
- (*return_iplist)[i].port = dcs[i].port;
+ r->port = dcs[i].port;
/* make sure it is a valid IP. I considered checking the negative
connection cache, but this is the wrong place for it. Maybe only
@@ -1069,15 +1071,11 @@
The standard reason for falling back to netbios lookups is that
our DNS server doesn't know anything about the DC's -- jerry */
- if ( is_zero_ip((*return_iplist)[i].ip) )
- continue;
-
- i++;
+ if ( ! is_zero_ip(r->ip) )
+ (*return_count)++;
}
TALLOC_FREE( dcs );
-
- *return_count = i;
return True;
}
More information about the samba-technical
mailing list