diff options
author | Bret Lambert <blambert@cvs.openbsd.org> | 2008-12-28 22:04:00 +0000 |
---|---|---|
committer | Bret Lambert <blambert@cvs.openbsd.org> | 2008-12-28 22:04:00 +0000 |
commit | a8d8a614bdf5c5bba0ed63b992edc95771086359 (patch) | |
tree | dffbfbd4b7ccc62dfd4fd68126173b26feb8a863 /usr.sbin | |
parent | 094520d65500e665b818b7286118eda4d21ba065 (diff) |
Plug some memory leakage in aldap_parse by calling aldap_freemsg
Let aldap_freemsg allow for a NULL ber_element tree, since it's now
possible to pass one in.
"looks fine to me :-)" aschrijver@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ypldap/aldap.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/ypldap/aldap.c b/usr.sbin/ypldap/aldap.c index 84bf03af9f1..e459b3cb165 100644 --- a/usr.sbin/ypldap/aldap.c +++ b/usr.sbin/ypldap/aldap.c @@ -1,5 +1,5 @@ -/* $Id: aldap.c,v 1.8 2008/12/27 19:46:12 aschrijver Exp $ */ -/* $OpenBSD: aldap.c,v 1.8 2008/12/27 19:46:12 aschrijver Exp $ */ +/* $Id: aldap.c,v 1.9 2008/12/28 22:03:59 blambert Exp $ */ +/* $OpenBSD: aldap.c,v 1.9 2008/12/28 22:03:59 blambert Exp $ */ /* * Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org> @@ -141,7 +141,7 @@ aldap_parse(struct aldap *ldap) return NULL; if((m->msg = ber_read_elements(&ldap->ber, NULL)) == NULL) - return NULL; + goto parsefail; LDAP_DEBUG("message", m->msg); @@ -168,7 +168,7 @@ aldap_parse(struct aldap *ldap) break; case LDAP_RES_SEARCH_ENTRY: if(ber_scanf_elements(m->protocol_op, "{eS{e", &m->dn, - &m->body.search.entries) != 0) + &m->body.search.entries) != 0) goto parsefail; break; case LDAP_RES_SEARCH_REFERENCE: @@ -179,13 +179,15 @@ aldap_parse(struct aldap *ldap) return m; parsefail: + aldap_freemsg(m); return NULL; } void aldap_freemsg(struct aldap_message *msg) { - ber_free_elements(msg->msg); + if (msg->msg) + ber_free_elements(msg->msg); free(msg); } |