summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-09-30 23:17:00 +0000
committerJeremy Allison <jra@samba.org>2002-09-30 23:17:00 +0000
commit512110f3386f43c262a31111a1280fd724cbee20 (patch)
treee82378b7520403e20e0b1bdb16a2449ca4c48cd9 /source3
parent4d2d5c4ace09a74420b74f1b9fbee04ecf5fa08b (diff)
downloadsamba-512110f3386f43c262a31111a1280fd724cbee20.tar.gz
samba-512110f3386f43c262a31111a1280fd724cbee20.tar.bz2
samba-512110f3386f43c262a31111a1280fd724cbee20.zip
Fix memory leak in getting DC list. Remember to exclude failed lookups.
Jeremy. (This used to be commit 80ee515d7a45965271be0274b0b3815032f27aa1)
Diffstat (limited to 'source3')
-rw-r--r--source3/nsswitch/winbindd_cm.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/source3/nsswitch/winbindd_cm.c b/source3/nsswitch/winbindd_cm.c
index 01f5569889..97d9159f66 100644
--- a/source3/nsswitch/winbindd_cm.c
+++ b/source3/nsswitch/winbindd_cm.c
@@ -140,16 +140,23 @@ static BOOL cm_ads_find_dc(const char *domain, struct in_addr *dc_ip, fstring sr
*/
static BOOL cm_rpc_find_dc(const char *domain, struct in_addr *dc_ip, fstring srv_name)
{
- struct in_addr *ip_list = NULL;
+ struct in_addr *ip_list = NULL, exclude_ip;
int count, i;
+ zero_ip(&exclude_ip);
+
/* Lookup domain controller name. Try the real PDC first to avoid
SAM sync delays */
- if (get_dc_list(True, domain, &ip_list, &count) &&
- name_status_find(domain, 0x1c, 0x20, ip_list[0], srv_name)) {
- *dc_ip = ip_list[0];
+
+ if (get_dc_list(True, domain, &ip_list, &count)) {
+ if (name_status_find(domain, 0x1c, 0x20, ip_list[0], srv_name)) {
+ *dc_ip = ip_list[0];
+ SAFE_FREE(ip_list);
+ return True;
+ }
+ /* Didn't get name, remember not to talk to this DC. */
+ exclude_ip = ip_list[0];
SAFE_FREE(ip_list);
- return True;
}
if (!get_dc_list(False, domain, &ip_list, &count)) {
@@ -157,9 +164,18 @@ static BOOL cm_rpc_find_dc(const char *domain, struct in_addr *dc_ip, fstring sr
return False;
}
+ /* Remove the entry we've already failed with (should be the PDC). */
+ for (i = 0; i < count; i++) {
+ if (ip_equal( exclude_ip, ip_list[i]))
+ zero_ip(&ip_list[i]);
+ }
+
/* Pick a nice close server */
/* Look for DC on local net */
for (i = 0; i < count; i++) {
+ if (is_zero_ip(ip_list[i]))
+ continue;
+
if (!is_local_net(ip_list[i]))
continue;