diff options
author | Rich Megginson <rmeggins@redhat.com> | 2010-03-04 14:02:29 -0700 |
---|---|---|
committer | Rich Megginson <rmeggins@redhat.com> | 2010-03-04 14:16:35 -0700 |
commit | 64db7873c668ec17fc92aedc37cbd9f476ded605 (patch) | |
tree | b01b97fbf892c4bc928143083081f9dfbcd9e953 /ldap/servers/slapd/main.c | |
parent | be57c970629e65df13921d4628dddc30457110cc (diff) | |
download | ds-64db7873c668ec17fc92aedc37cbd9f476ded605.tar.gz ds-64db7873c668ec17fc92aedc37cbd9f476ded605.tar.xz ds-64db7873c668ec17fc92aedc37cbd9f476ded605.zip |
fix various memory leaks
Reviewed by: nhosoi (Thanks!)
var/tmp/run_gssapi.vg.25032:Memory leak: 99 bytes duplicates: 5
> malloc() at vg_replace_malloc.c:207
> strdup() at /lib/libc-2.10.2.so
> slapi_ch_strdup() at ch_malloc.c:277
> ids_sasl_check_bind() at saslbind.c:924
> do_bind() at bind.c:382
> connection_threadmain() at connection.c:554
> --unknown-- at /lib/libnspr4.so
> start_thread() at /lib/libpthread-2.10.2.so
> clone() at /lib/libc-2.10.2.so
The problem is that ids_sasl_check_bind can reset SLAPI_BIND_TARGET to
a malloc'd value. The do_bind() code should check for this condition
and free it.
var/tmp/entryusn.vg.5997:Memory leak: 8 bytes duplicates: 8
> calloc() at vg_replace_malloc.c:397
> slapi_ch_calloc() at ch_malloc.c:243
> slapi_counter_new() at slapi_counter.c:95
> ldbm_usn_init() at ldbm_usn.c:86
> ldbm_back_start() at start.c:223
> plugin_call_func() at plugin.c:1417
> plugin_dependency_startall.clone.0() at plugin.c:1385
> main() at main.c:1138
The backend cleanup code should free be_usn_counter.
var/tmp/ipv6.vg.15561:Memory leak: 13 bytes duplicates: 3
> malloc() at vg_replace_malloc.c:207
> strdup() at /lib/libc-2.10.2.so
> slapi_ch_strdup() at ch_malloc.c:277
> config_get_listenhost() at libglobs.c:3674
> main() at main.c:874
var/tmp/ipv6.vg.15561:Memory leak: 13 bytes duplicates: 3
> malloc() at vg_replace_malloc.c:207
> strdup() at /lib/libc-2.10.2.so
> slapi_ch_strdup() at ch_malloc.c:277
> config_get_securelistenhost() at libglobs.c:3686
> main() at main.c:881
config_get_listenhost() and config_get_securelistenhost() return malloc'd
memory which must be freed.
var/tmp/dna_scen1.vg.4901:Memory leak: 248 bytes duplicates: 1
> malloc() at vg_replace_malloc.c:207
> nslberi_malloc() at io.c:1677
> ber_flatten() at io.c:1604
> create_NSDS50ReplicationExtopPayload() at repl_extop.c:218
> NSDS50EndReplicationRequest_new() at repl_extop.c:265
> release_replica() at repl5_protocol_util.c:469
> repl5_inc_run() at repl5_inc_protocol.c:1187
> prot_thread_main() at repl5_protocol.c:341
> --unknown-- at /lib/libnspr4.so
> start_thread() at /lib/libpthread-2.10.2.so
> clone() at /lib/libc-2.10.2.so
The payload was not being freed under all function exit conditions. So, just free it immediately after use.
var/tmp/dnarun.vg.2491:Memory leak: 27 bytes duplicates: 0
> malloc() at vg_replace_malloc.c:207
> slapi_ch_malloc() at ch_malloc.c:155
> slapi_entry_attr_get_charptr() at entry.c:2432
> dna_parse_config_entry() at dna.c:816
> dna_pre_op() at dna.c:2587
> plugin_call_func() at plugin.c:1417
> plugin_call_plugins() at plugin.c:1379
> op_shared_add() at add.c:606
> do_add() at add.c:232
> connection_threadmain() at connection.c:564
> --unknown-- at /lib/libnspr4.so
> start_thread() at /lib/libpthread-2.10.2.so
> clone() at /lib/libc-2.10.2.so
The value was not being freed under all conditions.
==9877== 1,890 (252 direct, 1,638 indirect) bytes in 3 blocks are definitely lost in loss record 1,628 of 1,725
==9877== at 0x47E0E5C: calloc (vg_replace_malloc.c:397)
==9877== by 0x4819D89: slapi_ch_calloc (ch_malloc.c:243)
==9877== by 0x48284A6: slapi_entry_alloc (entry.c:1686)
==9877== by 0x4829BA5: str2entry_dupcheck (entry.c:631)
==9877== by 0x482BB5D: slapi_str2entry_ext (entry.c:1194)
==9877== by 0xB2A8E9D: import_producer (import-threads.c:541)
==9877== by 0x72E1990: (within /lib/libnspr4.so)
==9877== by 0x731E8F4: start_thread (in /lib/libpthread-2.10.2.so)
==9877== by 0x75B2FCD: clone (in /lib/libc-2.10.2.so)
Make sure the entry or backentry are freed.
Diffstat (limited to 'ldap/servers/slapd/main.c')
-rw-r--r-- | ldap/servers/slapd/main.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c index 375fc4a2..5023dcd2 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -870,19 +870,26 @@ main( int argc, char **argv) if ((slapd_exemode == SLAPD_EXEMODE_SLAPD) || (slapd_exemode == SLAPD_EXEMODE_REFERRAL)) { + char *listenhost = config_get_listenhost(); + char *securelistenhost = config_get_securelistenhost(); ports_info.n_port = (unsigned short)n_port; - if ( slapd_listenhost2addr( config_get_listenhost(), + if ( slapd_listenhost2addr( listenhost, &ports_info.n_listenaddr ) != 0 || ports_info.n_listenaddr == NULL ) { + slapi_ch_free_string(&listenhost); + slapi_ch_free_string(&securelistenhost); return(1); } + slapi_ch_free_string(&listenhost); ports_info.s_port = (unsigned short)s_port; - if ( slapd_listenhost2addr( config_get_securelistenhost(), + if ( slapd_listenhost2addr( securelistenhost, &ports_info.s_listenaddr ) != 0 || ports_info.s_listenaddr == NULL ) { + slapi_ch_free_string(&securelistenhost); return(1); } + slapi_ch_free_string(&securelistenhost); #if defined(ENABLE_LDAPI) if( config_get_ldapi_switch() && |