diff options
author | Jose A. Rivera <jarrpa@redhat.com> | 2014-02-18 07:35:37 -0600 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2014-02-21 16:55:47 -0500 |
commit | 9a9e56943d186e5a8655b5d731a339e453da8ae8 (patch) | |
tree | f00befc04084a5bfd4eb10b3bc8dd28ff7d95e0e /source3/passdb | |
parent | 293aac0508d64551f549512d622e04ed22f297f6 (diff) | |
download | samba-9a9e56943d186e5a8655b5d731a339e453da8ae8.tar.gz |
passdb: Patch memory leak in pdb_ldap.c
Moved the call to the talloc autofree function to as early a point as
possible. init_ldap_from_sam() already calls smbldap_set_mod(), and there's
a chance that the init will fail after having already allocated memory for
&mods.
Coverity-Id: 1167997
Change-Id: Ic26bfb3c530f90aa885e447b8409deba49708d64
Reviewed-by: Ira Cooper <ira@samba.org>
Signed-off-by: Jose A. Rivera <jarrpa@redhat.com>
Reviewed-by: Simo Sorce <idra@samba.org>
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/pdb_ldap.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index 6be5fb62f5c..cea8627d7cc 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -5168,6 +5168,7 @@ static NTSTATUS ldapsam_create_user(struct pdb_methods *my_methods, uint32_t num_result; bool is_machine = False; bool add_posix = False; + bool init_okay = False; LDAPMod **mods = NULL; struct samu *user; char *filter; @@ -5285,7 +5286,10 @@ static NTSTATUS ldapsam_create_user(struct pdb_methods *my_methods, return NT_STATUS_UNSUCCESSFUL; } - if (!init_ldap_from_sam(ldap_state, entry, &mods, user, pdb_element_is_set_or_changed)) { + init_okay = init_ldap_from_sam(ldap_state, entry, &mods, user, pdb_element_is_set_or_changed); + smbldap_talloc_autofree_ldapmod(tmp_ctx, mods); + + if (!init_okay) { DEBUG(1,("ldapsam_create_user: Unable to fill user structs\n")); return NT_STATUS_UNSUCCESSFUL; } @@ -5371,9 +5375,7 @@ static NTSTATUS ldapsam_create_user(struct pdb_methods *my_methods, smbldap_set_mod(&mods, LDAP_MOD_ADD, "loginShell", shell); } - smbldap_talloc_autofree_ldapmod(tmp_ctx, mods); - - if (add_posix) { + if (add_posix) { rc = smbldap_add(ldap_state->smbldap_state, dn, mods); } else { rc = smbldap_modify(ldap_state->smbldap_state, dn, mods); |