summaryrefslogtreecommitdiffstats
path: root/ldap/servers/slapd/detach.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/detach.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/detach.c')
-rw-r--r--ldap/servers/slapd/detach.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/ldap/servers/slapd/detach.c b/ldap/servers/slapd/detach.c
index dc8f9881..51a369c0 100644
--- a/ldap/servers/slapd/detach.c
+++ b/ldap/servers/slapd/detach.c
@@ -75,7 +75,7 @@
#include <unistd.h>
#endif /* USE_SYSCONF */
-void
+int
detach( int slapd_exemode, int importexport_encrypt,
int s_port, daemon_ports_t *ports_info )
{
@@ -112,7 +112,7 @@ detach( int slapd_exemode, int importexport_encrypt,
/* call this right after the fork, but before closing stdin */
if (slapd_do_all_nss_ssl_init(slapd_exemode, importexport_encrypt,
s_port, ports_info)) {
- exit(1);
+ return 1;
}
workingdir = config_get_workingdir();
@@ -132,7 +132,7 @@ detach( int slapd_exemode, int importexport_encrypt,
} else {
/* calling config_set_workingdir to check for validity of directory, don't apply */
if (config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, workingdir, errorbuf, 0) == LDAP_OPERATIONS_ERROR) {
- exit(1);
+ return 1;
}
(void) chdir( workingdir );
slapi_ch_free_string(&workingdir);
@@ -140,7 +140,7 @@ detach( int slapd_exemode, int importexport_encrypt,
if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
perror( "/dev/null" );
- exit( 1 );
+ return 1;
}
(void) dup2( sd, 0 );
(void) dup2( sd, 1 );
@@ -160,12 +160,13 @@ detach( int slapd_exemode, int importexport_encrypt,
} else { /* not detaching - call nss/ssl init */
if (slapd_do_all_nss_ssl_init(slapd_exemode, importexport_encrypt,
s_port, ports_info)) {
- exit(1);
+ return 1;
}
}
(void) SIGNAL( SIGPIPE, SIG_IGN );
#endif /* _WIN32 */
+ return 0;
}