summaryrefslogtreecommitdiffstats
path: root/ldap/servers
diff options
context:
space:
mode:
Diffstat (limited to 'ldap/servers')
-rw-r--r--ldap/servers/plugins/distrib/distrib.c2
-rw-r--r--ldap/servers/plugins/replication/repl5_mtnode_ext.c1
-rw-r--r--ldap/servers/plugins/syntaxes/value.c2
-rw-r--r--ldap/servers/slapd/back-ldbm/ldbm_attrcrypt.c8
-rw-r--r--ldap/servers/slapd/back-ldbm/monitor.c21
-rw-r--r--ldap/servers/slapd/back-ldbm/vlv.c7
-rw-r--r--ldap/servers/slapd/config.c3
-rw-r--r--ldap/servers/slapd/daemon.c32
-rw-r--r--ldap/servers/slapd/plugin.c14
-rw-r--r--ldap/servers/slapd/pw.c5
-rw-r--r--ldap/servers/slapd/pw_mgmt.c4
-rw-r--r--ldap/servers/slapd/ssl.c16
12 files changed, 74 insertions, 41 deletions
diff --git a/ldap/servers/plugins/distrib/distrib.c b/ldap/servers/plugins/distrib/distrib.c
index 8b40a06a..6baf1cea 100644
--- a/ldap/servers/plugins/distrib/distrib.c
+++ b/ldap/servers/plugins/distrib/distrib.c
@@ -74,6 +74,7 @@ int alpha_distribution(Slapi_PBlock *pb, Slapi_DN * target_dn,
slapi_sdn_get_rdn(target_dn, rdn);
slapi_rdn_get_first(rdn, &rdn_type, &rdn_value);
c = rdn_value[0];
+ slapi_rdn_free(&rdn);
if (!(((c >= 'a') && (c <= 'z')) ||
((c >= 'A') && (c <= 'Z')) ))
@@ -81,7 +82,6 @@ int alpha_distribution(Slapi_PBlock *pb, Slapi_DN * target_dn,
return 0;
}
- slapi_rdn_free(&rdn);
/* for entries with rdn starting with alphabetic characters
* use the formula : (c - 'A') * be_count/26
diff --git a/ldap/servers/plugins/replication/repl5_mtnode_ext.c b/ldap/servers/plugins/replication/repl5_mtnode_ext.c
index b6c01d6e..ca39dbd9 100644
--- a/ldap/servers/plugins/replication/repl5_mtnode_ext.c
+++ b/ldap/servers/plugins/replication/repl5_mtnode_ext.c
@@ -121,6 +121,7 @@ multimaster_mtnode_extension_destructor (void* ext, void *object, void *parent)
object_release (mtnode_ext->replica);
mtnode_ext->replica = NULL;
}
+ slapi_ch_free((void **)&ext);
}
}
diff --git a/ldap/servers/plugins/syntaxes/value.c b/ldap/servers/plugins/syntaxes/value.c
index 4c201fd2..81ac113b 100644
--- a/ldap/servers/plugins/syntaxes/value.c
+++ b/ldap/servers/plugins/syntaxes/value.c
@@ -111,7 +111,7 @@ value_normalize(
np = ldap_utf8next(s);
if (np == NULL || np == s) break;
sz = np - s;
- memcpy(d,s,sz);
+ memmove(d,s,sz);
d += sz;
s += sz;
}
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_attrcrypt.c b/ldap/servers/slapd/back-ldbm/ldbm_attrcrypt.c
index 01673b9e..4190fbf1 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_attrcrypt.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_attrcrypt.c
@@ -166,6 +166,8 @@ attrcrypt_keymgmt_store_key(ldbm_instance *li, attrcrypt_cipher_state *acs, SECK
key_as_berval.bv_val = wrapped_symmetric_key.data;
key_as_berval.bv_len = wrapped_symmetric_key.len;
key_value = slapi_value_new_berval(&key_as_berval);
+ /* key_value is now a copy of key_as_berval - free wrapped_symmetric_key */
+ slapi_ch_free(&wrapped_symmetric_key.data);
slapi_entry_add_value(e, KEY_ATTRIBUTE_NAME, key_value);
slapi_value_free(&key_value);
/* Store the entry */
@@ -280,6 +282,9 @@ attrcrypt_fetch_public_key(SECKEYPublicKey **public_key)
}else {
ret = -1;
}
+ if (cert_name != default_cert_name) {
+ slapi_ch_free_string(&cert_name);
+ }
LDAPDebug(LDAP_DEBUG_TRACE,"<- attrcrypt_fetch_public_key\n", 0, 0, 0);
return ret;
}
@@ -322,6 +327,9 @@ attrcrypt_fetch_private_key(SECKEYPrivateKey **private_key)
} else {
ret = -1;
}
+ if (cert_name != default_cert_name) {
+ slapi_ch_free_string(&cert_name);
+ }
LDAPDebug(LDAP_DEBUG_TRACE,"<- attrcrypt_fetch_private_key\n", 0, 0, 0);
return ret;
}
diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c
index 81c86f12..e6583a81 100644
--- a/ldap/servers/slapd/back-ldbm/monitor.c
+++ b/ldap/servers/slapd/back-ldbm/monitor.c
@@ -40,6 +40,7 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
/* end of NPCTE fix for bugid 544365 */
DB_MPOOL_FSTAT **mpfstat = NULL;
int i,j;
+ char *absolute_pathname = NULL;
/* Get the LDBM Info structure for the ldbm backend */
if (inst->inst_be->be_database == NULL) {
@@ -109,7 +110,6 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
#ifdef _WIN32
int fpos = 0;
#endif
- char *absolute_pathname = NULL;
/* only print out stats on files used by this instance */
if (strlen(mpfstat[i]->file_name) < strlen(inst->inst_dir_name))
@@ -118,13 +118,11 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
strlen(inst->inst_dir_name)) != 0)
continue;
- /* Since the filenames are now relative, we need to construct an absolute version
- * for the purpose of stat() etc below...
- */
- if (absolute_pathname) {
- slapi_ch_free_string(&absolute_pathname);
- }
- absolute_pathname = slapi_ch_smprintf("%s%c%s" , inst->inst_parent_dir_name, get_sep(inst->inst_parent_dir_name), mpfstat[i]->file_name );
+ /* Since the filenames are now relative, we need to construct an absolute version
+ * for the purpose of stat() etc below...
+ */
+ slapi_ch_free_string(&absolute_pathname);
+ absolute_pathname = slapi_ch_smprintf("%s%c%s" , inst->inst_parent_dir_name, get_sep(inst->inst_parent_dir_name), mpfstat[i]->file_name );
/* NPCTE fix for bugid 544365, esc 0. <P.R> <04-Jul-2001> */
/* Hide statistic of deleted files (mainly indexes) */
@@ -168,12 +166,11 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
sprintf(buf, "%u", mpfstat[i]->st_page_out);
MSETF("dbFilePageOut-%d", i);
- if (absolute_pathname) {
- slapi_ch_free_string(&absolute_pathname);
- }
-
+ slapi_ch_free_string(&absolute_pathname);
}
+ slapi_ch_free_string(&absolute_pathname);
+
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR + DB_VERSION_PATCH <= 3204
/* In DB 3.2.4 and earlier, we need to free each element */
for (i = 0; mpfstat[i]; i++)
diff --git a/ldap/servers/slapd/back-ldbm/vlv.c b/ldap/servers/slapd/back-ldbm/vlv.c
index ff3aa79a..32719817 100644
--- a/ldap/servers/slapd/back-ldbm/vlv.c
+++ b/ldap/servers/slapd/back-ldbm/vlv.c
@@ -1455,6 +1455,8 @@ vlv_trim_candidates_byvalue(backend *be, const IDList *candidates, const sort_sp
*/
Slapi_Value **csn_value = valueset_get_valuearray(&attr->a_present_values);
struct berval **entry_value = /* xxxPINAKI needs modification attr->a_vals */NULL;
+ PRBool needFree = PR_FALSE;
+
if(sort_control->mr_pb!=NULL)
{
struct berval **tmp_entry_value = NULL;
@@ -1466,6 +1468,7 @@ vlv_trim_candidates_byvalue(backend *be, const IDList *candidates, const sort_sp
else
{
valuearray_get_bervalarray(csn_value,&entry_value);
+ needFree = PR_TRUE; /* entry_value is a copy */
}
if(!sort_control->order)
{
@@ -1475,6 +1478,10 @@ vlv_trim_candidates_byvalue(backend *be, const IDList *candidates, const sort_sp
{
match= sort_attr_compare((struct berval**)typedown_value, entry_value, compare_fn);
}
+ if (needFree) {
+ ber_bvecfree((struct berval**)entry_value);
+ entry_value = NULL;
+ }
}
else
{
diff --git a/ldap/servers/slapd/config.c b/ldap/servers/slapd/config.c
index 0eabc408..29b5af51 100644
--- a/ldap/servers/slapd/config.c
+++ b/ldap/servers/slapd/config.c
@@ -304,6 +304,7 @@ slapd_bootstrap_config(const char *configdir)
{
LDAPDebug(LDAP_DEBUG_ANY, "The plugin entry [%s] in the configfile %s was invalid\n", slapi_entry_get_dn(e), configfile, 0);
rc = 0;
+ slapi_sdn_done(&plug_dn);
goto bail;
}
}
@@ -324,6 +325,7 @@ slapd_bootstrap_config(const char *configdir)
{
LDAPDebug(LDAP_DEBUG_ANY, "The plugin entry [%s] in the configfile %s was invalid\n", slapi_entry_get_dn(e), configfile, 0);
rc = 0;
+ slapi_sdn_done(&plug_dn);
goto bail;
}
}
@@ -454,6 +456,7 @@ slapd_bootstrap_config(const char *configdir)
}
bail:
+ slapi_ch_free((void **)&buf);
return rc;
}
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 66088cbc..4e46095a 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -1834,14 +1834,15 @@ handle_new_connection(Connection_Table *ct, int tcps, PRFileDesc *pr_acceptfd, i
*the commented code that follows each of the next two
*blocks of code
*/
- struct lber_x_ext_io_fns *func_pointers = malloc(LBER_X_EXTIO_FNS_SIZE);
- func_pointers->lbextiofn_size = LBER_X_EXTIO_FNS_SIZE;
- func_pointers->lbextiofn_read = secure_read_function;
- func_pointers->lbextiofn_write = secure_write_function;
- func_pointers->lbextiofn_writev = NULL;
- func_pointers->lbextiofn_socket_arg = (struct lextiof_socket_private *) pr_clonefd;
+ struct lber_x_ext_io_fns func_pointers;
+ memset(&func_pointers, 0, sizeof(func_pointers));
+ func_pointers.lbextiofn_size = LBER_X_EXTIO_FNS_SIZE;
+ func_pointers.lbextiofn_read = secure_read_function;
+ func_pointers.lbextiofn_write = secure_write_function;
+ func_pointers.lbextiofn_writev = NULL;
+ func_pointers.lbextiofn_socket_arg = (struct lextiof_socket_private *) pr_clonefd;
ber_sockbuf_set_option( conn->c_sb,
- LBER_SOCKBUF_OPT_EXT_IO_FNS, func_pointers);
+ LBER_SOCKBUF_OPT_EXT_IO_FNS, &func_pointers);
/* changed here by Cheston
ber_sockbuf_set_option( conn->c_sb,
@@ -1850,18 +1851,19 @@ handle_new_connection(Connection_Table *ct, int tcps, PRFileDesc *pr_acceptfd, i
LBER_SOCKBUF_OPT_WRITE_FN, (void *)secure_write_function );
*/
} else {
- struct lber_x_ext_io_fns *func_pointers = malloc(LBER_X_EXTIO_FNS_SIZE);
- func_pointers->lbextiofn_size = LBER_X_EXTIO_FNS_SIZE;
- func_pointers->lbextiofn_read = read_function;
- func_pointers->lbextiofn_write = write_function;
- func_pointers->lbextiofn_writev = NULL;
+ struct lber_x_ext_io_fns func_pointers;
+ memset(&func_pointers, 0, sizeof(func_pointers));
+ func_pointers.lbextiofn_size = LBER_X_EXTIO_FNS_SIZE;
+ func_pointers.lbextiofn_read = read_function;
+ func_pointers.lbextiofn_write = write_function;
+ func_pointers.lbextiofn_writev = NULL;
#ifdef _WIN32
- func_pointers->lbextiofn_socket_arg = (struct lextiof_socket_private *) ns;
+ func_pointers.lbextiofn_socket_arg = (struct lextiof_socket_private *) ns;
#else
- func_pointers->lbextiofn_socket_arg = (struct lextiof_socket_private *) pr_clonefd;
+ func_pointers.lbextiofn_socket_arg = (struct lextiof_socket_private *) pr_clonefd;
#endif
ber_sockbuf_set_option( conn->c_sb,
- LBER_SOCKBUF_OPT_EXT_IO_FNS, func_pointers);
+ LBER_SOCKBUF_OPT_EXT_IO_FNS, &func_pointers);
/*
ber_sockbuf_set_option( conn->c_sb,
LBER_SOCKBUF_OPT_READ_FN, (void *)read_function );
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index 42ded667..bd7c92ba 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -883,6 +883,11 @@ plugin_dependency_startall(int argc, char** argv, char *errmsg, int operation)
* create an operation and include that in the pblock as well,
* because these two items are stored in the operation parameters.
*/
+ /* WARNING: memory leak here - op is only freed by a pblock_done,
+ and this only happens below if the plugin is enabled - a short
+ circuit goto bail may also cause a leak - however, since this
+ only happens a few times at startup, this is not a very serious
+ leak - just after the call to plugin_call_one */
Operation *op = internal_operation_new(SLAPI_OPERATION_ADD, 0);
slapi_pblock_set(&(config[plugin_index].pb), SLAPI_OPERATION, op);
slapi_pblock_set(&(config[plugin_index].pb), SLAPI_TARGET_DN,
@@ -1164,16 +1169,16 @@ bail:
if(config)
{
- /*
index = 0;
while(index < total_plugins)
{
+/*
if(config[index].depends_named_list)
{
slapi_ch_free((void**)&(config[index].depends_named_list));
}
-
+*/
if(config[index].depends_type_list)
{
i = 0;
@@ -1187,13 +1192,12 @@ bail:
slapi_ch_free((void**)&(config[index].depends_type_list));
}
-
+/*
slapi_ch_free((void**)&(config[index].name));
slapi_ch_free((void**)&(config[index].type));
-
+*/
index++;
}
- */
slapi_ch_free((void**)&config);
}
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index 76e6c5d6..a664f008 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -1343,7 +1343,12 @@ new_passwdPolicy(Slapi_PBlock *pb, char *dn)
}
} /* end of for() loop */
+ if (pw_entry) {
+ slapi_entry_free(pw_entry);
+ }
return pwdpolicy;
+ } else if ( e ) {
+ slapi_entry_free( e );
}
}
}
diff --git a/ldap/servers/slapd/pw_mgmt.c b/ldap/servers/slapd/pw_mgmt.c
index def09c02..ee102159 100644
--- a/ldap/servers/slapd/pw_mgmt.c
+++ b/ldap/servers/slapd/pw_mgmt.c
@@ -121,7 +121,8 @@ skip:
pw_exp_date != NOT_FIRST_TIME &&
(diff_t = difftime ( pw_exp_date,
parse_genTime ( cur_time_str ))) <= 0 ) {
-
+
+ slapi_ch_free_string(&cur_time_str); /* only need this above */
/* password has expired. Check the value of
* passwordGraceUserTime and compare it
* against the value of passwordGraceLimit */
@@ -175,7 +176,6 @@ skip:
/* Apply current modifications */
pw_apply_mods(dn, &smods);
slapi_mods_done(&smods);
- slapi_ch_free((void **) &cur_time_str );
delete_passwdPolicy(&pwpolicy);
return (-1);
}
diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c
index 93a7ae94..5a9445b4 100644
--- a/ldap/servers/slapd/ssl.c
+++ b/ldap/servers/slapd/ssl.c
@@ -700,6 +700,7 @@ int slapd_ssl_init2(PRFileDesc **fd, int startTLS)
SECKEYPrivateKey *key = NULL;
char errorbuf[BUFSIZ];
char *val = NULL;
+ char *default_val = NULL;
int nFamilies = 0;
SECStatus sslStatus;
int slapd_SSLclientAuth;
@@ -888,8 +889,8 @@ int slapd_ssl_init2(PRFileDesc **fd, int startTLS)
CERT_DestroyCertificate(cert);
cert = NULL;
}
+ slapi_ch_free((void **) &personality);
if (SECSuccess != rv) {
- slapi_ch_free((void **) &personality);
freeConfigEntry( &e );
continue;
}
@@ -973,18 +974,19 @@ int slapd_ssl_init2(PRFileDesc **fd, int startTLS)
configDN, errorCode, slapd_pr_strerror(errorCode));
switch( SLAPD_SSLCLIENTAUTH_DEFAULT ) {
case SLAPD_SSLCLIENTAUTH_OFF:
- val = "off";
+ default_val = "off";
break;
case SLAPD_SSLCLIENTAUTH_ALLOWED:
- val = "allowed";
+ default_val = "allowed";
break;
case SLAPD_SSLCLIENTAUTH_REQUIRED:
- val = "required";
+ default_val = "required";
break;
default:
- val = "allowed";
+ default_val = "allowed";
break;
}
+ val = default_val;
}
if( config_set_SSLclientAuth( "nssslclientauth", val, errorbuf,
CONFIG_APPLY ) != LDAP_SUCCESS ) {
@@ -995,6 +997,9 @@ int slapd_ssl_init2(PRFileDesc **fd, int startTLS)
"and \"required\". (" SLAPI_COMPONENT_NAME_NSPR " error %d - %s)",
val, errorbuf, errorCode, slapd_pr_strerror(errorCode));
}
+ if (val != default_val) {
+ slapi_ch_free_string(&val);
+ }
freeConfigEntry( &e );
@@ -1386,6 +1391,7 @@ char* slapd_get_tmp_dir()
}
PR_snprintf(tmp,sizeof(tmp),"%s/tmp",instanceDir);
+ slapi_ch_free_string(&instanceDir);
#if defined( XP_WIN32 )
for(ilen=0;ilen < strlen(tmp); ilen++)