Fix bug 5419: memory leak in ads_do_search_all_args() when enumerating 1000s of entries
authorSteven Danneman <sdanneman@sd-ubuntu.(none)>
Sat, 26 Apr 2008 01:34:46 +0000 (18:34 -0700)
committerJeremy Allison <jra@samba.org>
Sat, 26 Apr 2008 15:11:20 +0000 (08:11 -0700)
commit778a5414b1148ea767020b5330b076fed666694f
treed889aeb242d3326782b01f4954d337bc801e6eed
parent17ade782b9037500c282555e5a2612a863af58d8
Fix bug 5419: memory leak in ads_do_search_all_args() when enumerating 1000s of entries

The ads_do_search_all_args() function attempts to string together several
LDAPMessage structures, returned across several paged ldap requests, into a
single LDAPMessage structure.  It does this by pulling entries off the second
LDAPMessage structure and appending them to the first via the OpenLDAP specific
ldap_add_result_entry() call.

The problem with this approach is it skips non-entry messages such as the
result, and controls.  These messages are leaked.

The short term solution as suggested by Volker is to replace the ads_*_entry()
calls with ads_*_message() calls so we don't leak any messages.

This fixes the leak but doesn't remove the dependence on the OpenLDAP specific
implementation of ldap_add_result_entry().
(This used to be commit f1a5405409c396df394611e2a234522572d2860a)
source3/include/ads_protos.h
source3/libads/ldap.c