diff options
author | Gerald Carter <jerry@samba.org> | 2003-11-14 03:36:27 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2003-11-14 03:36:27 +0000 |
commit | 7301471a6a12244cd398e3c81c310ffc2b663c53 (patch) | |
tree | b5657c08a5ec255f62c3e0ad8a8ec51b5d957273 /source3/sam | |
parent | 716dd32809b1fe2e6a836700297145c170d103c0 (diff) | |
download | samba-7301471a6a12244cd398e3c81c310ffc2b663c53.tar.gz samba-7301471a6a12244cd398e3c81c310ffc2b663c53.tar.bz2 samba-7301471a6a12244cd398e3c81c310ffc2b663c53.zip |
fix more memory leaks in the LDAP backend code; patches from metze
(This used to be commit 89a8c607af4ca67fcefe285480f7c9b832f6720c)
Diffstat (limited to 'source3/sam')
-rw-r--r-- | source3/sam/idmap_ldap.c | 18 |
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() )); |