diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 6dafe5b33..d69f5bbb1 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2014-05-23 Corinna Vinschen + + * autoload.cc (ldap_memfreeW): Remove. + (ldap_msgfree): Import. + * ldap.cc: Throughout, use ldap_msgfree to free LDAPMessage memory, + rather than ldap_memfreeW. + (cyg_ldap::next_account): Immediately abandon search when quiting from + search. + 2014-05-22 Corinna Vinschen * autoload.cc (ldap_abandon): Remove. diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc index fa2cd65c5..5cc296e25 100644 --- a/winsup/cygwin/autoload.cc +++ b/winsup/cygwin/autoload.cc @@ -593,7 +593,7 @@ LoadDLLfunc (ldap_get_next_page_s, 0, wldap32) LoadDLLfunc (ldap_get_valuesW, 0, wldap32) LoadDLLfunc (ldap_get_values_lenW, 0, wldap32) LoadDLLfunc (ldap_initW, 0, wldap32) -LoadDLLfunc (ldap_memfreeW, 0, wldap32) +LoadDLLfunc (ldap_msgfree, 0, wldap32) LoadDLLfunc (ldap_next_entry, 0, wldap32) LoadDLLfunc (ldap_search_abandon_page, 0, wldap32) LoadDLLfunc (ldap_search_init_pageW, 0, wldap32) diff --git a/winsup/cygwin/ldap.cc b/winsup/cygwin/ldap.cc index 72f16defb..cee07c333 100644 --- a/winsup/cygwin/ldap.cc +++ b/winsup/cygwin/ldap.cc @@ -172,7 +172,7 @@ cyg_ldap::open (PCWSTR domain) } ldap_value_freeW (val); val = NULL; - ldap_memfreeW ((PWCHAR) msg); + ldap_msgfree (msg); msg = entry = NULL; return true; err: close (); @@ -187,9 +187,9 @@ cyg_ldap::close () if (lh) ldap_unbind (lh); if (srch_msg) - ldap_memfreeW ((PWCHAR) srch_msg); + ldap_msgfree (srch_msg); if (msg) - ldap_memfreeW ((PWCHAR) msg); + ldap_msgfree (msg); if (val) ldap_value_freeW (val); if (rootdse) @@ -214,7 +214,7 @@ cyg_ldap::fetch_ad_account (PSID sid, bool group, PCWSTR domain) if (msg) { - ldap_memfreeW ((PWCHAR) msg); + ldap_msgfree (msg); msg = entry = NULL; } if (val) @@ -318,7 +318,7 @@ cyg_ldap::next_account (cygsid &sid) ldap_value_free_len (bval); return true; } - ldap_memfreeW ((PWCHAR) srch_msg); + ldap_msgfree (srch_msg); srch_msg = srch_entry = NULL; } do @@ -327,19 +327,18 @@ cyg_ldap::next_account (cygsid &sid) } while (ret == LDAP_SUCCESS && ldap_count_entries (lh, srch_msg) == 0); if (ret == LDAP_NO_RESULTS_RETURNED) - return false; - if (ret != LDAP_SUCCESS) - { - debug_printf ("ldap_result() error 0x%02x", ret); - return false; - } - if ((srch_entry = ldap_first_entry (lh, srch_msg)) - && (bval = ldap_get_values_lenW (lh, srch_entry, sid_attr[0]))) + ; + else if (ret != LDAP_SUCCESS) + debug_printf ("ldap_result() error 0x%02x", ret); + else if ((srch_entry = ldap_first_entry (lh, srch_msg)) + && (bval = ldap_get_values_lenW (lh, srch_entry, sid_attr[0]))) { sid = (PSID) bval[0]->bv_val; ldap_value_free_len (bval); return true; } + ldap_search_abandon_page (lh, srch_id); + srch_id = NULL; return false; } @@ -351,7 +350,7 @@ cyg_ldap::fetch_posix_offset_for_domain (PCWSTR domain) if (msg) { - ldap_memfreeW ((PWCHAR) msg); + ldap_msgfree (msg); msg = entry = NULL; } if (val) @@ -407,7 +406,7 @@ cyg_ldap::fetch_unix_sid_from_ad (uint32_t id, cygsid &sid, bool group) if (msg) { - ldap_memfreeW ((PWCHAR) msg); + ldap_msgfree (msg); msg = entry = NULL; } if (group) @@ -439,7 +438,7 @@ cyg_ldap::fetch_unix_name_from_rfc2307 (uint32_t id, bool group) if (msg) { - ldap_memfreeW ((PWCHAR) msg); + ldap_msgfree (msg); msg = entry = NULL; } if (val)