summaryrefslogtreecommitdiff
path: root/source3/sam
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2003-11-14 03:28:03 +0000
committerGerald Carter <jerry@samba.org>2003-11-14 03:28:03 +0000
commit36558f8f2bc34bdcff2c0e6602ea065b16aa9e21 (patch)
tree6cda24f6914364ff2806e17bbfed9f1c96b9815c /source3/sam
parent281e293331f20d9341ebaf555f10ef339952048c (diff)
downloadsamba-36558f8f2bc34bdcff2c0e6602ea065b16aa9e21.tar.gz
samba-36558f8f2bc34bdcff2c0e6602ea065b16aa9e21.tar.bz2
samba-36558f8f2bc34bdcff2c0e6602ea065b16aa9e21.zip
fix more memory leaks in the LDAP backend code; patches from metze
(This used to be commit e079c8842a24ff4f50483bea8ca6b11db4b2dc99)
Diffstat (limited to 'source3/sam')
-rw-r--r--source3/sam/idmap_ldap.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/source3/sam/idmap_ldap.c b/source3/sam/idmap_ldap.c
index 2a94de755a..db1bb74de5 100644
--- a/source3/sam/idmap_ldap.c
+++ b/source3/sam/idmap_ldap.c
@@ -234,6 +234,7 @@ static NTSTATUS ldap_next_rid(struct ldap_idmap_state *state, uint32 *rid,
next_rid = *rid+1;
if (next_rid >= alg_rid_base) {
+ ldap_msgfree(domain_result);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -382,7 +383,7 @@ static NTSTATUS ldap_allocate_id(unid_t *id, int id_type)
pstring id_str, new_id_str;
LDAPMod **mods = NULL;
const char *type;
- char *dn;
+ char *dn = NULL;
char **attr_list;
pstring filter;
uid_t luid, huid;
@@ -455,12 +456,15 @@ static NTSTATUS ldap_allocate_id(unid_t *id, int id_type)
smbldap_set_mod( &mods, LDAP_MOD_DELETE, type, id_str );
smbldap_set_mod( &mods, LDAP_MOD_ADD, type, new_id_str );
-
+
+ if (mods == NULL) {
+ DEBUG(0,("ldap_allocate_id: smbldap_set_mod() failed.\n"));
+ goto out;
+ }
+
rc = smbldap_modify(ldap_state.smbldap_state, dn, mods);
- SAFE_FREE(dn);
ldap_mods_free( mods, True );
-
if (rc != LDAP_SUCCESS) {
DEBUG(0,("ldap_allocate_id: Failed to allocate new %s. ldap_modify() failed.\n",
type));
@@ -469,6 +473,10 @@ static NTSTATUS ldap_allocate_id(unid_t *id, int id_type)
ret = NT_STATUS_OK;
out:
+ SAFE_FREE(dn);
+ if (result != NULL)
+ ldap_msgfree(result);
+
return ret;
}
@@ -683,6 +691,8 @@ static NTSTATUS verify_idpool( void )
count = ldap_count_entries(ldap_state.smbldap_state->ldap_struct, result);
+ ldap_msgfree(result);
+
if ( count > 1 ) {
DEBUG(0,("ldap_idmap_init: multiple entries returned from %s (base == %s)\n",
filter, lp_ldap_idmap_suffix() ));