[tpop3d-discuss] Memory leak?
Chris Lightfoot
chris at ex-parrot.com
Thu, 9 May 2002 21:14:03 +0100
On Thu, May 09, 2002 at 12:08:41PM -0700, Marc Lewis wrote:
> On Thu, May 09, 2002 at 11:20:45AM +0100, Chris Lightfoot wrote:
[...]
> > Cheers. I'll see if I can reproduce anything with my test
> > OpenLDAP installation.
>
> I'm very interested to hear your results.
OK, I've discovered a few SNAFUs; the following patch
ought to fix them:
diff -u -r1.5 auth_ldap.c
--- auth_ldap.c 2002/02/25 18:16:05 1.5
+++ auth_ldap.c 2002/05/09 20:08:45
@@ -341,11 +341,10 @@
group = xstrdup(*vals);
ldap_value_free(vals);
+ ldap_memfree(attr);
}
- /* Do NOT need to free the ber, apparently-- ldap_next_attribute frees
- * it when it returns NULL. */
- if (attr) ldap_memfree(attr);
+ ber_free(ber, 0);
/* Check that we've retrieved all the attributes we need. */
#define GOT_ATTR(a) if (ldapinfo.attr.##a && !a) { \
@@ -394,8 +393,11 @@
fail:
if (ldapres) ldap_msgfree(ldapres);
-/* if (user_attr) ldap_msgfree(user_attr);*/
- if (user_dn) free(user_dn);
+
+ /* Ugly: force the LDAP library to free user_addr. */
+ while (ldap_next_entry(ldapinfo.ldap, ldapres));
+
+ if (user_dn) ldap_memfree(user_dn);
xfree(filter);
-- I could have sworn that the last documentation I read
told me that I'd got this right before.
I can't comment on the PAM trouble you're having, except
for my earlier snide comments about PAM itself. I shall
try to dig out a more recent RedHat machine to test it
on, but I can't see myself installing the PAM LDAP stuff.
You mentioned that you'd had some spurious failed
authentications. What error message is logged in these
cases?
--
``Smile,'' someone said. ``It could be worse.'' So I did, and it was.