From 9265113fa31adfc13cf2e30d4f362e25ada15582 Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Nov 02 2011 01:12:50 +0000 Subject: Bug 750625 - Fix Coverity (11109, 11110, 11111) Uninitialized pointer read https://bugzilla.redhat.com/show_bug.cgi?id=750625 plugins/replication/cl5_config.c (changelog5_read_config) Bug Description: Using uninitialized value "config.dir". changelog config is set with the changelog config entry in changelog5_read_config. If the search for the config entry succeeds but there's no entry returned (actually, there is no such case, though), the config structure is not initialized. Fix Description: if changelog config entry search is success and no entry is returned, initialize the config structure with NULLs. --- diff --git a/ldap/servers/plugins/replication/cl5_config.c b/ldap/servers/plugins/replication/cl5_config.c index 09c5eca..980cb7f 100644 --- a/ldap/servers/plugins/replication/cl5_config.c +++ b/ldap/servers/plugins/replication/cl5_config.c @@ -125,29 +125,35 @@ int changelog5_read_config (changelog5Config *config) int rc = LDAP_SUCCESS; Slapi_PBlock *pb; - pb = slapi_pblock_new (); - slapi_search_internal_set_pb (pb, CONFIG_BASE, LDAP_SCOPE_BASE, CONFIG_FILTER, NULL, 0, NULL, - NULL, repl_get_plugin_identity (PLUGIN_MULTIMASTER_REPLICATION), 0); + pb = slapi_pblock_new (); + slapi_search_internal_set_pb (pb, CONFIG_BASE, LDAP_SCOPE_BASE, + CONFIG_FILTER, NULL, 0, NULL, NULL, + repl_get_plugin_identity (PLUGIN_MULTIMASTER_REPLICATION), 0); slapi_search_internal_pb (pb); - slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_RESULT, &rc ); - if ( LDAP_SUCCESS == rc ) + slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_RESULT, &rc ); + if ( LDAP_SUCCESS == rc ) { - Slapi_Entry **entries = NULL; - slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries ); - if ( NULL != entries && NULL != entries[0]) + Slapi_Entry **entries = NULL; + slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries ); + if ( NULL != entries && NULL != entries[0]) { - /* Extract the config info from the changelog entry */ + /* Extract the config info from the changelog entry */ changelog5_extract_config(entries[0], config); - } - } + } + else + { + memset (config, 0, sizeof (*config)); + rc = LDAP_SUCCESS; + } + } else { memset (config, 0, sizeof (*config)); - rc = LDAP_SUCCESS; + rc = LDAP_SUCCESS; } - slapi_free_search_results_internal(pb); - slapi_pblock_destroy(pb); + slapi_free_search_results_internal(pb); + slapi_pblock_destroy(pb); return rc; }