summaryrefslogtreecommitdiffstats
path: root/ldap/servers/slapd/mapping_tree.c
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2009-07-08 09:57:04 -0600
committerRich Megginson <rmeggins@redhat.com>2009-07-14 12:35:11 -0600
commita4240192f344a1a172cfdf8609661b90435b5db3 (patch)
treec6ea1519c184971c66f171252e1ebd5493a8b610 /ldap/servers/slapd/mapping_tree.c
parent386ba57d421ee2d59a267d52d63bd88cbf20c435 (diff)
downloadds-a4240192f344a1a172cfdf8609661b90435b5db3.tar.gz
ds-a4240192f344a1a172cfdf8609661b90435b5db3.tar.xz
ds-a4240192f344a1a172cfdf8609661b90435b5db3.zip
Reduce noise reported by valgrind
valgrind is a very useful tool - however, the directory server produces a lot of false positives that have to be suppressed in order to get to the useful information. These patches attempt to reduce some of that noise. 1) aclparse - should calculate the length of the string _after_ trimming the spaces 2) something about random number generation causes some of the bits to be uninitialized, and valgrind doesn't like it - this patch doesn't eliminate the error, just reduces it 3) use initialized memory when generating hashes - also remove "magic numbers" 4) bin.c - slapi_value_get_string must not be used with unterminated (binary) values 5) we get these odd valgrind reports from deep within bdb about invalid reads and uninitialized memory - I thought perhaps because we were initializing DBT structures with = {0} which the bdb docs says is not sufficient - they recommend memset or bzero 6) There are some small memory leaks during attrcrypt initialization and in error cases 7) error message in ldif2ldbm.c was attempting to print the Slapi_DN structure rather than getting the char *dn 8) After we call NSS_Initialize, we must call the NSS shutdown functions to clean up the caches and other data structures, otherwise NSS will leak memory. This is harmless since it happens at exit, but valgrind reports hundreds of memory leaks. The solution is to make sure we go through a single exit point after NSS_Initialize. This means many places that just called exit() must instead return with a real return value. This mostly affected main.c, detach.c, and a couple of other places called during startup. 9) minor memory leaks in mapping tree initialization 10) sasl_map.c - should not call this in referral mode 11) minor memory leaks during ssl init Reviewed by: nkinder, nhosoi (Thanks!)
Diffstat (limited to 'ldap/servers/slapd/mapping_tree.c')
-rw-r--r--ldap/servers/slapd/mapping_tree.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
index c682597a..479909a3 100644
--- a/ldap/servers/slapd/mapping_tree.c
+++ b/ldap/servers/slapd/mapping_tree.c
@@ -556,11 +556,10 @@ get_backends_from_attr(Slapi_Attr *attr, backend ***be_list, char ***be_names,
/*
* Description:
- * Release the memory allocated by the routine above.
- * Call this when the backend not put into structure and need to cleanup these tmp allocations
+ * Free the data allocated for mapping tree node arrays
*/
static void
-free_get_backends_from_attr(backend ***be_list, char ***be_names,
+free_mapping_tree_node_arrays(backend ***be_list, char ***be_names,
int ** be_states, int *be_list_count)
{
int i;
@@ -671,7 +670,7 @@ mapping_tree_entry_add(Slapi_Entry *entry, mapping_tree_node **newnodep )
if (get_backends_from_attr(attr, &be_list, &be_names, &be_states,
&be_list_count, &be_list_size, NULL)) {
- free_get_backends_from_attr(&be_list, &be_names, &be_states, &be_list_count);
+ free_mapping_tree_node_arrays(&be_list, &be_names, &be_states, &be_list_count);
slapi_sdn_free(&subtree);
return lderr;
}
@@ -776,7 +775,7 @@ mapping_tree_entry_add(Slapi_Entry *entry, mapping_tree_node **newnodep )
"ERROR: node %s must define a backend\n",
slapi_entry_get_dn(entry), 0, 0);
slapi_sdn_free(&subtree);
- free_get_backends_from_attr(&be_list, &be_names, &be_states, &be_list_count);
+ free_mapping_tree_node_arrays(&be_list, &be_names, &be_states, &be_list_count);
return lderr;
}
if (((state == MTN_REFERRAL) || (state == MTN_REFERRAL_ON_UPDATE))
@@ -786,7 +785,7 @@ mapping_tree_entry_add(Slapi_Entry *entry, mapping_tree_node **newnodep )
"ERROR: node %s must define referrals to be in referral state\n",
slapi_entry_get_dn(entry), 0, 0);
slapi_sdn_free(&subtree);
- free_get_backends_from_attr(&be_list, &be_names, &be_states, &be_list_count);
+ free_mapping_tree_node_arrays(&be_list, &be_names, &be_states, &be_list_count);
return lderr;
}
@@ -803,7 +802,7 @@ mapping_tree_entry_add(Slapi_Entry *entry, mapping_tree_node **newnodep )
slapi_sdn_free(&subtree);
slapi_ch_free((void **) &plugin_funct);
slapi_ch_free((void **) &plugin_lib);
- free_get_backends_from_attr(&be_list, &be_names, &be_states, &be_list_count);
+ free_mapping_tree_node_arrays(&be_list, &be_names, &be_states, &be_list_count);
return lderr;
}
}
@@ -822,7 +821,7 @@ mapping_tree_entry_add(Slapi_Entry *entry, mapping_tree_node **newnodep )
slapi_sdn_free(&subtree);
slapi_ch_free((void **) &plugin_funct);
slapi_ch_free((void **) &plugin_lib);
- free_get_backends_from_attr(&be_list, &be_names, &be_states, &be_list_count);
+ free_mapping_tree_node_arrays(&be_list, &be_names, &be_states, &be_list_count);
return lderr;
}
@@ -1119,7 +1118,7 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor
else if (get_backends_from_attr(attr, &backends, &be_names,
&be_states, &be_list_count, &be_list_size, node))
{
- free_get_backends_from_attr(&backends, &be_names, &be_states, &be_list_count);
+ free_mapping_tree_node_arrays(&backends, &be_names, &be_states, &be_list_count);
slapi_sdn_free(&subtree);
*returncode = LDAP_UNWILLING_TO_PERFORM;
return SLAPI_DSE_CALLBACK_ERROR;
@@ -1132,11 +1131,13 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor
PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "mapping tree entry need at least one nsslapd-backend\n");
*returncode = LDAP_UNWILLING_TO_PERFORM;
mtn_unlock();
- free_get_backends_from_attr(&backends, &be_names, &be_states, &be_list_count);
+ free_mapping_tree_node_arrays(&backends, &be_names, &be_states, &be_list_count);
slapi_sdn_free(&subtree);
return SLAPI_DSE_CALLBACK_ERROR;
}
+ /* free any old data */
+ free_mapping_tree_node_arrays(&node->mtn_be, &node->mtn_backend_names, &node->mtn_be_states, &node->mtn_be_count);
node->mtn_be_states = be_states;
node->mtn_be = backends;
node->mtn_backend_names = be_names;
@@ -1642,7 +1643,7 @@ mapping_tree_init()
}
static void
-mtn_free_node (mapping_tree_node **node)
+mtn_free_node (mapping_tree_node **node)
{
mapping_tree_node *child = (*node)->mtn_children;
@@ -1668,16 +1669,13 @@ mtn_free_node (mapping_tree_node **node)
if ((*node)->mtn_be_count > 0)
{
- if ((*node)->mtn_be)
- slapi_ch_free((void **) &((*node)->mtn_be));
-
- if ((*node)->mtn_backend_names)
- slapi_ch_free((void **) &((*node)->mtn_backend_names));
-
- if ((*node)->mtn_be_states)
- slapi_ch_free((void **) &((*node)->mtn_be_states));
+ free_mapping_tree_node_arrays(&((*node)->mtn_be), &((*node)->mtn_backend_names),
+ &((*node)->mtn_be_states), &((*node)->mtn_be_count));
}
+ slapi_ch_free_string(&((*node)->mtn_dstr_plg_lib));
+ slapi_ch_free_string(&((*node)->mtn_dstr_plg_name));
+
slapi_ch_free ((void**) node);
}