summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alex@spline.inf.fu-berlin.de>2016-01-16 01:04:51 +0100
committerAlexander Sulfrian <alex@spline.inf.fu-berlin.de>2016-01-16 01:04:51 +0100
commitfea79207f34702b4e784af343eba90cac72055b8 (patch)
treea991d4f30169737c00fafa4ae50993cf1ea81bd5
parent667c6a7e0697f9ed21db32e8043411c9329afad5 (diff)
downloadldap-plugin-fea79207f34702b4e784af343eba90cac72055b8.tar.gz
ldap-plugin-fea79207f34702b4e784af343eba90cac72055b8.tar.bz2
ldap-plugin-fea79207f34702b4e784af343eba90cac72055b8.zip
Free more memory
-rw-r--r--service_passwords.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/service_passwords.c b/service_passwords.c
index bf70770..1a60fc5 100644
--- a/service_passwords.c
+++ b/service_passwords.c
@@ -108,9 +108,12 @@ static int dn_contains_uid(const char *dn)
if (rc != 0 || slapi_valueset_count(uid_values) == 0) {
/* empty uid value */
rc = 1;
- goto fail1;
+ goto fail2;
}
+fail2:
+ slapi_valueset_free(uid_values);
+
fail1:
slapi_entry_free(entry);
@@ -162,16 +165,19 @@ static char* is_service(const char *dn)
if (rc != 0 || cn == NULL) {
/* no value in cn attribute */
service = NULL;
- goto fail1;
+ goto fail2;
}
if (*cn == NULL) {
service = NULL;
- goto fail1;
+ goto fail2;
}
service = slapi_ch_strdup((*cn)->bv_val);
+fail2:
+ ber_bvecfree(cn);
+
fail1:
slapi_entry_free(entry);
@@ -221,14 +227,18 @@ static int auth(char *dn, struct berval *credentials)
rc |= slapi_attr_get_values(attr, &userPasswords);
if (rc != 0 || userPasswords == NULL) {
rc = 1;
- goto fail1;
+ goto fail2;
}
/* check password */
rc |= slapi_pw_find(userPasswords, credentials);
+fail2:
+ ber_bvecfree(userPasswords);
+
fail1:
slapi_entry_free(entry);
+
return rc;
}
@@ -458,21 +468,28 @@ static int pre_entry(Slapi_PBlock *pb)
/* ignore service_password entries */
parent_dn = slapi_dn_parent(result_dn);
- if (dn_contains_uid(parent_dn) == 0) {
+ rc |= dn_contains_uid(parent_dn);
+ slapi_ch_free_string(&parent_dn);
+
+ if (rc == 0) {
rc = -1;
goto fail1;
}
- slapi_ch_free_string(&parent_dn);
/* modify the dn of the returned entry */
if (dn_contains_uid(result_dn) == 0) {
/* TODO: style */
+ new_entry = slapi_entry_dup(entry);
+ ber_bvfree(new_entry->e_name);
+ ber_bvfree(new_entry->e_nname);
+
snprintf(rdn, 254, "cn=%s", service);
new_dn = slapi_dn_plus_rdn(result_dn, rdn);
- new_entry = slapi_entry_dup(entry);
slapi_entry_set_dn(new_entry, new_dn);
slapi_ch_free_string(&new_dn);
+
slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY, new_entry);
+ slapi_entry_free(entry);
}
fail1: