summaryrefslogtreecommitdiffstats
path: root/ipa-server/ipa-slapi-plugins
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2007-11-19 19:34:27 -0500
committerSimo Sorce <ssorce@redhat.com>2007-11-19 19:34:27 -0500
commit56d67b86e18112c9f059e7bcd3ac51fc21f941af (patch)
treef6c483b3da7cb61026eb9b6cec34c0bfe6a27bbd /ipa-server/ipa-slapi-plugins
parent44f9f13e170abdc6998efe78ccd764b9d38ab79d (diff)
downloadfreeipa-56d67b86e18112c9f059e7bcd3ac51fc21f941af.tar.gz
freeipa-56d67b86e18112c9f059e7bcd3ac51fc21f941af.tar.xz
freeipa-56d67b86e18112c9f059e7bcd3ac51fc21f941af.zip
Fix bad segfault when pwvals is null
Diffstat (limited to 'ipa-server/ipa-slapi-plugins')
-rw-r--r--ipa-server/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c58
1 files changed, 24 insertions, 34 deletions
diff --git a/ipa-server/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c b/ipa-server/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c
index c629e018b..558fdaea0 100644
--- a/ipa-server/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c
+++ b/ipa-server/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c
@@ -852,9 +852,8 @@ static int ipapwd_getPolicy(const char *dn, Slapi_Entry *target, Slapi_Entry **e
slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
"ipapwd_getPolicy: Couldn't find policy, err (%d)\n",
res?res:ret);
- slapi_free_search_results_internal(pb);
- slapi_sdn_free(&sdn);
- return -1;
+ ret = -1;
+ goto done;
}
/* get entries */
@@ -862,9 +861,8 @@ static int ipapwd_getPolicy(const char *dn, Slapi_Entry *target, Slapi_Entry **e
if (!es) {
slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
"ipapwd_getPolicy: No entries ?!");
- slapi_free_search_results_internal(pb);
- slapi_sdn_free(&sdn);
- return -1;
+ ret = -1;
+ goto done;
}
/* count entries */
@@ -874,9 +872,8 @@ static int ipapwd_getPolicy(const char *dn, Slapi_Entry *target, Slapi_Entry **e
if (i == 1) {
*e = slapi_entry_dup(es[0]);
- slapi_free_search_results_internal(pb);
- slapi_sdn_free(&sdn);
- return 0;
+ ret = 0;
+ goto done;
}
/* count number of RDNs in DN */
@@ -884,9 +881,8 @@ static int ipapwd_getPolicy(const char *dn, Slapi_Entry *target, Slapi_Entry **e
if (!edn) {
slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
"ipapwd_getPolicy: ldap_explode_dn(dn) failed ?!");
- slapi_free_search_results_internal(pb);
- slapi_sdn_free(&sdn);
- return -1;
+ ret = -1;
+ goto done;
}
for (rdnc = 0; edn[rdnc]; rdnc++) /* count */ ;
ldap_value_free(edn);
@@ -925,16 +921,17 @@ static int ipapwd_getPolicy(const char *dn, Slapi_Entry *target, Slapi_Entry **e
}
if (pe == NULL) {
- slapi_free_search_results_internal(pb);
- slapi_sdn_free(&sdn);
- return -1;
+ ret = -1;
+ goto done;
}
*e = slapi_entry_dup(pe);
-
+ ret = 0;
+done:
slapi_free_search_results_internal(pb);
+ slapi_pblock_destroy(pb);
slapi_sdn_free(&sdn);
- return 0;
+ return ret;
}
#define GENERALIZED_TIME_LENGTH 15
@@ -1538,10 +1535,12 @@ static int ipapwd_SetPassword(struct ipapwd_data *data)
slapi_value_free(&svals[i]);
}
free(svals);
- for (i = 0; pwvals[i]; i++) {
- slapi_value_free(&pwvals[i]);
+ if (pwvals) {
+ for (i = 0; pwvals[i]; i++) {
+ slapi_value_free(&pwvals[i]);
+ }
+ free(pwvals);
}
- free(pwvals);
return ret;
}
@@ -1723,7 +1722,6 @@ static int ipapwd_extop(Slapi_PBlock *pb)
if (tag == LDAP_EXTOP_PASSMOD_TAG_OLDPWD )
{
if (ber_scanf(ber, "a", &oldPasswd) == LBER_ERROR) {
- slapi_ch_free_string(&oldPasswd);
slapi_log_error(SLAPI_LOG_FATAL, "ipa_pwd_extop", "ber_scanf failed :{\n");
errMesg = "ber_scanf failed at oldPasswd parse.\n";
rc = LDAP_PROTOCOL_ERROR;
@@ -1736,7 +1734,6 @@ static int ipapwd_extop(Slapi_PBlock *pb)
if (tag == LDAP_EXTOP_PASSMOD_TAG_NEWPWD )
{
if (ber_scanf(ber, "a", &newPasswd) == LBER_ERROR) {
- slapi_ch_free_string(&newPasswd);
slapi_log_error(SLAPI_LOG_FATAL, "ipa_pwd_extop", "ber_scanf failed :{\n");
errMesg = "ber_scanf failed at newPasswd parse.\n";
rc = LDAP_PROTOCOL_ERROR;
@@ -1913,19 +1910,11 @@ free_and_return:
slapi_pblock_set(pb, SLAPI_ORIGINAL_TARGET, NULL);
slapi_ch_free_string(&authmethod);
- if (targetEntry != NULL) {
- slapi_entry_free(targetEntry);
- }
-
- if (ber != NULL) {
- ber_free(ber, 1);
- ber = NULL;
- }
+ if (targetEntry) slapi_entry_free(targetEntry);
+ if (ber) ber_free(ber, 1);
- slapi_log_error(SLAPI_LOG_PLUGIN, "ipa_pwd_extop",
- errMesg ? errMesg : "success");
+ slapi_log_error(SLAPI_LOG_PLUGIN, "ipa_pwd_extop", errMesg ? errMesg : "success");
slapi_send_ldap_result(pb, rc, NULL, errMesg, 0, NULL);
-
return SLAPI_PLUGIN_EXTENDED_SENT_RESULT;
@@ -2014,8 +2003,9 @@ static int ipapwd_getMasterKey(const char *realm_dn)
kmkey->contents = malloc(mkey->bv_len);
if (!kmkey->contents) {
slapi_log_error( SLAPI_LOG_FATAL, "ipapwd_start", "Out of memory!\n");
- free(kmkey);
+ ber_bvfree(mkey);
ber_free(be, 1);
+ free(kmkey);
slapi_entry_free(realm_entry);
return LDAP_OPERATIONS_ERROR;
}