andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From 6bc7e9a2ffc09f235d60cd31ed610b62b0d47799 Mon Sep 17 00:00:00 2001
dc8c34
From: Mark Reynolds <mreynolds@redhat.com>
dc8c34
Date: Mon, 24 Mar 2014 19:05:36 -0700
dc8c34
Subject: [PATCH 191/225] Ticket 47740 - Fix coverity issues(part 7)
dc8c34
dc8c34
12496 - resource leak - ldap/servers/slapd/mapping_tree.c
dc8c34
12497 - resource leak - ldap/servers/slapd/mapping_tree.c
dc8c34
12500 - resource leak - ldap/servers/plugins/chainingdb/cb_instance.c
dc8c34
12501 - resource leak - ldap/servers/plugins/sync/sync_refresh.c
dc8c34
12506 - resource leak - ldap/servers/plugins/chainingdb/cb_config.c
dc8c34
12509 - reosurce leak - ldap/servers/plugins/chainingdb/cb_bind.c
dc8c34
12510 - reosurce leak - lib/ldaputil/certmap.c
dc8c34
12538 - resource leak - ldap/servers/plugins/mep/mep.c
dc8c34
12539 - resource leak - ldap/servers/plugins/posix-winsync/posix-winsync.c
dc8c34
12540 - resource leak - ldap/servers/plugins/posix-winsync/posix-winsync.c
dc8c34
12541 - resource leak - ldap/servers/plugins/posix-winsync/posix-winsync.c
dc8c34
12542 - resource leak - ldap/servers/plugins/posix-winsync/posix-winsync.c
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/47740
dc8c34
dc8c34
Reviewed by: nhosoi(Thanks!)
dc8c34
(cherry picked from commit 99609ceebad3bfb1926065ca4c0337847ccf38dd)
dc8c34
(cherry picked from commit 1ed422213cd8b8d7adbcf5ec35a0e3a7b2e14328)
dc8c34
---
dc8c34
 ldap/servers/plugins/chainingdb/cb_bind.c     |  43 +++----
dc8c34
 ldap/servers/plugins/chainingdb/cb_config.c   | 175 ++++++++++++++------------
dc8c34
 ldap/servers/plugins/chainingdb/cb_instance.c |   2 +-
dc8c34
 ldap/servers/plugins/mep/mep.c                |   1 +
dc8c34
 ldap/servers/slapd/mapping_tree.c             |  13 +-
dc8c34
 lib/ldaputil/certmap.c                        |   4 +-
dc8c34
 6 files changed, 125 insertions(+), 113 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/plugins/chainingdb/cb_bind.c b/ldap/servers/plugins/chainingdb/cb_bind.c
dc8c34
index 7c22931..827916e 100644
dc8c34
--- a/ldap/servers/plugins/chainingdb/cb_bind.c
dc8c34
+++ b/ldap/servers/plugins/chainingdb/cb_bind.c
dc8c34
@@ -230,29 +230,27 @@ release_and_return:
dc8c34
 int
dc8c34
 chainingdb_bind( Slapi_PBlock *pb )
dc8c34
 {
dc8c34
-
dc8c34
-	int 			status=LDAP_SUCCESS;
dc8c34
-	int 			allocated_errmsg;
dc8c34
-	int 			rc=LDAP_SUCCESS;
dc8c34
-	cb_backend_instance 	*cb;
dc8c34
-	Slapi_Backend		*be;
dc8c34
-	const char      *dn = NULL;
dc8c34
-	Slapi_DN        *sdn = NULL;
dc8c34
-	Slapi_DN        *mysdn = NULL;
dc8c34
-	int                     method;
dc8c34
-	struct berval           *creds, **urls;
dc8c34
-	char 			*matcheddn,*errmsg;
dc8c34
-	LDAPControl         	**reqctrls, **resctrls, **ctrls;
dc8c34
-	char 			* mechanism;
dc8c34
-	int 			freectrls=1;
dc8c34
-	int 			bind_retry;
dc8c34
+	cb_backend_instance *cb;
dc8c34
+	Slapi_Backend *be;
dc8c34
+	struct berval *creds = NULL, **urls = NULL;
dc8c34
+	const char *dn = NULL;
dc8c34
+	Slapi_DN *sdn = NULL;
dc8c34
+	Slapi_DN *mysdn = NULL;
dc8c34
+	char *matcheddn = NULL, *errmsg = NULL;
dc8c34
+	LDAPControl **reqctrls = NULL, **resctrls = NULL, **ctrls = NULL;
dc8c34
+	char *mechanism = NULL;
dc8c34
+	int status=LDAP_SUCCESS;
dc8c34
+	int allocated_errmsg = 0;
dc8c34
+	int rc = LDAP_SUCCESS;
dc8c34
+	int freectrls = 1;
dc8c34
+	int bind_retry;
dc8c34
+	int method;
dc8c34
 	
dc8c34
 	if ( LDAP_SUCCESS != (rc = cb_forward_operation(pb) )) {
dc8c34
 		cb_send_ldap_result( pb, rc, NULL, "Chaining forbidden", 0, NULL );
dc8c34
 		return SLAPI_BIND_FAIL;
dc8c34
 	}
dc8c34
 
dc8c34
-	ctrls=NULL;
dc8c34
 	/* don't add proxy auth control. use this call to check for supported   */
dc8c34
 	/* controls only.							*/
dc8c34
 	if ( LDAP_SUCCESS != ( rc = cb_update_controls( pb, NULL, &ctrls, 0 )) ) {
dc8c34
@@ -285,11 +283,6 @@ chainingdb_bind( Slapi_PBlock *pb )
dc8c34
 
dc8c34
 	cb_update_monitor_info(pb,cb,SLAPI_OPERATION_BIND);
dc8c34
 
dc8c34
-	matcheddn=errmsg=NULL;
dc8c34
-	allocated_errmsg = 0;
dc8c34
-	resctrls=NULL;
dc8c34
-	urls=NULL;
dc8c34
-
dc8c34
 	/* Check wether the chaining BE is available or not */
dc8c34
 	if ( cb_check_availability( cb, pb ) == FARMSERVER_UNAVAILABLE ){
dc8c34
 		slapi_sdn_free(&mysdn);
dc8c34
@@ -313,12 +306,14 @@ chainingdb_bind( Slapi_PBlock *pb )
dc8c34
 			cb_ping_farm(cb,NULL,0);
dc8c34
 		}
dc8c34
 		rc = LDAP_OPERATIONS_ERROR;
dc8c34
+	} else {
dc8c34
+		allocated_errmsg = 1;
dc8c34
 	}
dc8c34
 
dc8c34
 	if ( rc != LDAP_USER_CANCELLED ) {  /* not abandoned */
dc8c34
 		if ( resctrls != NULL ) {
dc8c34
 			slapi_pblock_set( pb, SLAPI_RESCONTROLS, resctrls );
dc8c34
-			freectrls=0;
dc8c34
+			freectrls = 0;
dc8c34
 		}
dc8c34
 
dc8c34
 		if ( rc != LDAP_SUCCESS ) {
dc8c34
@@ -332,7 +327,7 @@ chainingdb_bind( Slapi_PBlock *pb )
dc8c34
 	if ( freectrls && ( resctrls != NULL )) {
dc8c34
 		ldap_controls_free( resctrls );
dc8c34
 	}
dc8c34
-	slapi_ch_free((void **)& matcheddn );
dc8c34
+	slapi_ch_free_string(&matcheddn);
dc8c34
 	if ( allocated_errmsg ) {
dc8c34
 		slapi_ch_free_string(&errmsg);
dc8c34
 	}
dc8c34
diff --git a/ldap/servers/plugins/chainingdb/cb_config.c b/ldap/servers/plugins/chainingdb/cb_config.c
dc8c34
index d05470c..7cbd7ba 100644
dc8c34
--- a/ldap/servers/plugins/chainingdb/cb_config.c
dc8c34
+++ b/ldap/servers/plugins/chainingdb/cb_config.c
dc8c34
@@ -404,23 +404,23 @@ int
dc8c34
 cb_config_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, 
dc8c34
 	char *returntext, void *arg) 
dc8c34
 {
dc8c34
-        LDAPMod 	**mods;
dc8c34
+	LDAPMod 	**mods;
dc8c34
 	char 		*attr_name;
dc8c34
 	int 		i,j;
dc8c34
-        cb_backend 	*cb = (cb_backend *) arg;
dc8c34
+	cb_backend 	*cb = (cb_backend *) arg;
dc8c34
 
dc8c34
 	CB_ASSERT (cb!=NULL);
dc8c34
 
dc8c34
-        slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
dc8c34
+	slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
dc8c34
 
dc8c34
-        for (i = 0; mods[i] ; i++) {
dc8c34
+	for (i = 0; mods[i] ; i++) {
dc8c34
 		attr_name = mods[i]->mod_type;
dc8c34
 
dc8c34
-               	if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_FORWARD_CTRLS )) {
dc8c34
+		if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_FORWARD_CTRLS )) {
dc8c34
 			char * config_attr_value;
dc8c34
 			int done=0;
dc8c34
-        		for (j = 0; mods[i]->mod_bvalues && mods[i]->mod_bvalues[j]; j++) {
dc8c34
-		                config_attr_value = (char *) mods[i]->mod_bvalues[j]->bv_val;
dc8c34
+        	for (j = 0; mods[i]->mod_bvalues && mods[i]->mod_bvalues[j]; j++) {
dc8c34
+        		config_attr_value = (char *) mods[i]->mod_bvalues[j]->bv_val;
dc8c34
 				if (!cb_is_control_forwardable(cb,config_attr_value)) {
dc8c34
 				        slapi_log_error(SLAPI_LOG_PLUGIN,CB_PLUGIN_SUBSYSTEM,
dc8c34
 						"control %s can't be forwarded.\n",config_attr_value);
dc8c34
@@ -428,100 +428,111 @@ cb_config_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entr
dc8c34
 					return SLAPI_DSE_CALLBACK_ERROR;
dc8c34
 				}
dc8c34
 
dc8c34
-			        if (SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) {
dc8c34
+				if(SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) {
dc8c34
 					if (!done) {
dc8c34
 						cb_unregister_all_supported_control(cb);
dc8c34
 						done=1;
dc8c34
 					}
dc8c34
 					cb_register_supported_control(cb,config_attr_value,0);
dc8c34
-				} else
dc8c34
+				} else {
dc8c34
 			        if (SLAPI_IS_MOD_ADD(mods[i]->mod_op)) {
dc8c34
-					cb_register_supported_control(cb,config_attr_value,0);
dc8c34
-				} else 
dc8c34
-			        if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
dc8c34
-					cb_unregister_supported_control(cb,config_attr_value,0);
dc8c34
+			        	cb_register_supported_control(cb,config_attr_value,0);
dc8c34
+			        } else {
dc8c34
+			        	if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
dc8c34
+			        		cb_unregister_supported_control(cb,config_attr_value,0);
dc8c34
+			        	}
dc8c34
+			        }
dc8c34
 				}
dc8c34
 			}
dc8c34
-			if (NULL == mods[i]->mod_bvalues)
dc8c34
+			if (NULL == mods[i]->mod_bvalues){
dc8c34
 				cb_unregister_all_supported_control(cb);
dc8c34
-		} else
dc8c34
-                if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_DEBUG )) {
dc8c34
-			/* assume single-valued */
dc8c34
-                        if (mods[i]->mod_op & LDAP_MOD_DELETE)
dc8c34
-				cb_set_debug(0);
dc8c34
-			else if (SLAPI_IS_MOD_ADD(mods[i]->mod_op))
dc8c34
-				cb_set_debug(1);
dc8c34
-		} else
dc8c34
- 		if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_CHAINING_COMPONENTS )) {
dc8c34
-                        char * config_attr_value;
dc8c34
-                        int done=0;
dc8c34
-
dc8c34
-                        slapi_rwlock_wrlock(cb->config.rwl_config_lock);
dc8c34
-
dc8c34
-                        for (j = 0; mods[i]->mod_bvalues && mods[i]->mod_bvalues[j]; j++) {
dc8c34
-                                config_attr_value = (char *) mods[i]->mod_bvalues[j]->bv_val;
dc8c34
-                                if (SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) {
dc8c34
-                                        if (!done) {
dc8c34
-					        charray_free(cb->config.chaining_components);
dc8c34
-					        cb->config.chaining_components=NULL;
dc8c34
-                                                done=1;
dc8c34
-                                        }
dc8c34
-					/* XXXSD assume dn. Normalize it */
dc8c34
-					charray_add(&cb->config.chaining_components,
dc8c34
-						slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
dc8c34
-                                } else
dc8c34
-                                if (SLAPI_IS_MOD_ADD(mods[i]->mod_op)) {
dc8c34
-					charray_add(&cb->config.chaining_components,
dc8c34
-						slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
dc8c34
-                                } else
dc8c34
-                                if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
dc8c34
-					charray_remove(cb->config.chaining_components,
dc8c34
-						slapi_dn_normalize(slapi_ch_strdup(config_attr_value)),
dc8c34
-						0 /* freeit */);
dc8c34
-                                }
dc8c34
-                        }
dc8c34
-                        if (NULL == mods[i]->mod_bvalues) {
dc8c34
-				charray_free(cb->config.chaining_components);
dc8c34
-				cb->config.chaining_components=NULL;
dc8c34
 			}
dc8c34
+		} else {
dc8c34
+			if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_DEBUG )) {
dc8c34
+				/* assume single-valued */
dc8c34
+				if (mods[i]->mod_op & LDAP_MOD_DELETE){
dc8c34
+					cb_set_debug(0);
dc8c34
+				} else if (SLAPI_IS_MOD_ADD(mods[i]->mod_op)) {
dc8c34
+					cb_set_debug(1);
dc8c34
+				}
dc8c34
+			} else {
dc8c34
+				if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_CHAINING_COMPONENTS )) {
dc8c34
+					char * config_attr_value;
dc8c34
+					int done=0;
dc8c34
+
dc8c34
+					slapi_rwlock_wrlock(cb->config.rwl_config_lock);
dc8c34
+
dc8c34
+					for (j = 0; mods[i]->mod_bvalues && mods[i]->mod_bvalues[j]; j++) {
dc8c34
+						config_attr_value = (char *) mods[i]->mod_bvalues[j]->bv_val;
dc8c34
+						if (SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) {
dc8c34
+							if (!done) {
dc8c34
+								charray_free(cb->config.chaining_components);
dc8c34
+								cb->config.chaining_components=NULL;
dc8c34
+								done=1;
dc8c34
+							}
dc8c34
+							/* XXXSD assume dn. Normalize it */
dc8c34
+							charray_add(&cb->config.chaining_components,
dc8c34
+							        slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
dc8c34
+						} else {
dc8c34
+							if (SLAPI_IS_MOD_ADD(mods[i]->mod_op)) {
dc8c34
+								charray_add(&cb->config.chaining_components,
dc8c34
+								        slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
dc8c34
+							} else {
dc8c34
+								if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
dc8c34
+									char *remove_val = slapi_ch_strdup(config_attr_value);
dc8c34
+									charray_remove(cb->config.chaining_components,
dc8c34
+									        slapi_dn_normalize(remove_val),	0 /* freeit */);
dc8c34
+									slapi_ch_free_string(&remove_val);
dc8c34
+								}
dc8c34
+							}
dc8c34
+						}
dc8c34
+					}
dc8c34
+					if (NULL == mods[i]->mod_bvalues) {
dc8c34
+						charray_free(cb->config.chaining_components);
dc8c34
+						cb->config.chaining_components=NULL;
dc8c34
+					}
dc8c34
 
dc8c34
-                        slapi_rwlock_unlock(cb->config.rwl_config_lock);
dc8c34
-		} else
dc8c34
-			if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_CHAINABLE_COMPONENTS )) {
dc8c34
-				char *config_attr_value;
dc8c34
-				char *attr_val;
dc8c34
-				int done=0;
dc8c34
-
dc8c34
-				slapi_rwlock_wrlock(cb->config.rwl_config_lock);
dc8c34
-
dc8c34
-				for (j = 0; mods[i]->mod_bvalues && mods[i]->mod_bvalues[j]; j++) {
dc8c34
-					config_attr_value = (char *) mods[i]->mod_bvalues[j]->bv_val;
dc8c34
-					if (SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) {
dc8c34
-						if (!done) {
dc8c34
+					slapi_rwlock_unlock(cb->config.rwl_config_lock);
dc8c34
+				} else {
dc8c34
+					if ( !strcasecmp ( attr_name, CB_CONFIG_GLOBAL_CHAINABLE_COMPONENTS )) {
dc8c34
+						char *config_attr_value;
dc8c34
+						char *attr_val;
dc8c34
+						int done=0;
dc8c34
+
dc8c34
+						slapi_rwlock_wrlock(cb->config.rwl_config_lock);
dc8c34
+
dc8c34
+						for (j = 0; mods[i]->mod_bvalues && mods[i]->mod_bvalues[j]; j++) {
dc8c34
+							config_attr_value = (char *) mods[i]->mod_bvalues[j]->bv_val;
dc8c34
+							if (SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) {
dc8c34
+								if (!done) {
dc8c34
+									charray_free(cb->config.chainable_components);
dc8c34
+									cb->config.chainable_components=NULL;
dc8c34
+									done=1;
dc8c34
+								}
dc8c34
+								charray_add(&cb->config.chainable_components,
dc8c34
+								        slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
dc8c34
+							} else if (SLAPI_IS_MOD_ADD(mods[i]->mod_op)) {
dc8c34
+								charray_add(&cb->config.chainable_components,
dc8c34
+								        slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
dc8c34
+							} else if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
dc8c34
+								attr_val = slapi_dn_normalize(slapi_ch_strdup(config_attr_value));
dc8c34
+								charray_remove(cb->config.chainable_components, attr_val, 0 /* freeit */);
dc8c34
+								slapi_ch_free_string(&attr_val);
dc8c34
+							}
dc8c34
+						}
dc8c34
+						if (NULL == mods[i]->mod_bvalues) {
dc8c34
 							charray_free(cb->config.chainable_components);
dc8c34
 							cb->config.chainable_components=NULL;
dc8c34
-							done=1;
dc8c34
 						}
dc8c34
-						charray_add(&cb->config.chainable_components,
dc8c34
-						slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
dc8c34
-					} else if (SLAPI_IS_MOD_ADD(mods[i]->mod_op)) {
dc8c34
-						charray_add(&cb->config.chainable_components,
dc8c34
-						slapi_dn_normalize(slapi_ch_strdup(config_attr_value)));
dc8c34
-					} else if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
dc8c34
-						attr_val = slapi_dn_normalize(slapi_ch_strdup(config_attr_value));
dc8c34
-						charray_remove(cb->config.chainable_components, attr_val, 0 /* freeit */);
dc8c34
-						slapi_ch_free_string(&attr_val);
dc8c34
+
dc8c34
+						slapi_rwlock_unlock(cb->config.rwl_config_lock);
dc8c34
 					}
dc8c34
 				}
dc8c34
-				if (NULL == mods[i]->mod_bvalues) {
dc8c34
-					charray_free(cb->config.chainable_components);
dc8c34
-					cb->config.chainable_components=NULL;
dc8c34
-				}
dc8c34
-
dc8c34
-				slapi_rwlock_unlock(cb->config.rwl_config_lock);
dc8c34
+			}
dc8c34
 		}
dc8c34
 	}
dc8c34
 	*returncode=LDAP_SUCCESS;
dc8c34
+
dc8c34
 	return SLAPI_DSE_CALLBACK_OK;
dc8c34
 }
dc8c34
 
dc8c34
diff --git a/ldap/servers/plugins/chainingdb/cb_instance.c b/ldap/servers/plugins/chainingdb/cb_instance.c
dc8c34
index 86bb635..db0cf37 100644
dc8c34
--- a/ldap/servers/plugins/chainingdb/cb_instance.c
dc8c34
+++ b/ldap/servers/plugins/chainingdb/cb_instance.c
dc8c34
@@ -405,7 +405,7 @@ int cb_instance_modify_config_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor
dc8c34
                                	} else
dc8c34
                                	if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
dc8c34
                                        	charray_remove(inst->illegal_attributes,
dc8c34
-                                               	slapi_ch_strdup(config_attr_value),
dc8c34
+                                               	config_attr_value,
dc8c34
 												0 /* freeit */);
dc8c34
                                	}
dc8c34
                         }
dc8c34
diff --git a/ldap/servers/plugins/mep/mep.c b/ldap/servers/plugins/mep/mep.c
dc8c34
index f8e3c2b..d81ecf4 100644
dc8c34
--- a/ldap/servers/plugins/mep/mep.c
dc8c34
+++ b/ldap/servers/plugins/mep/mep.c
dc8c34
@@ -2637,6 +2637,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
dc8c34
         /* Bail out if the plug-in close function was just called. */
dc8c34
         if (!g_plugin_started) {
dc8c34
             mep_config_unlock();
dc8c34
+            slapi_ch_free_string(&managed_dn);
dc8c34
             slapi_pblock_destroy(mep_pb);
dc8c34
             return 0;
dc8c34
         }
dc8c34
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
dc8c34
index 12d9205..2e8cbff 100644
dc8c34
--- a/ldap/servers/slapd/mapping_tree.c
dc8c34
+++ b/ldap/servers/slapd/mapping_tree.c
dc8c34
@@ -1284,11 +1284,15 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor
dc8c34
                 *returncode = LDAP_OPERATIONS_ERROR;
dc8c34
                 mtn_unlock();
dc8c34
                 slapi_sdn_free(&subtree);
dc8c34
+                slapi_ch_free_string(&plugin_fct);
dc8c34
+                slapi_ch_free_string(&plugin_lib);
dc8c34
                 return SLAPI_DSE_CALLBACK_ERROR;
dc8c34
             }
dc8c34
 
dc8c34
             mtn_unlock();
dc8c34
             slapi_sdn_free(&subtree);
dc8c34
+            slapi_ch_free_string(&plugin_fct);
dc8c34
+            slapi_ch_free_string(&plugin_lib);
dc8c34
             *returncode = LDAP_SUCCESS;
dc8c34
             return SLAPI_DSE_CALLBACK_OK;
dc8c34
         }
dc8c34
@@ -1301,18 +1305,18 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor
dc8c34
                 slapi_entry_attr_find(entryAfter,
dc8c34
                              "nsslapd-distribution-funct", &attr);
dc8c34
                 slapi_attr_first_value(attr, &val;;
dc8c34
+                slapi_ch_free_string(&plugin_fct);
dc8c34
                 if (NULL == val) {
dc8c34
                     LDAPDebug(LDAP_DEBUG_ANY,
dc8c34
                     "Warning: The nsslapd-distribution-funct attribute"
dc8c34
                     " has no value for the mapping tree node %s\n",
dc8c34
                     slapi_entry_get_dn(entryAfter), 0, 0);
dc8c34
-                    plugin_fct = NULL;
dc8c34
                 }
dc8c34
                 plugin_fct = slapi_ch_strdup(slapi_value_get_string(val));
dc8c34
             }
dc8c34
             else if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op))
dc8c34
             {
dc8c34
-                plugin_fct = NULL;
dc8c34
+                slapi_ch_free_string(&plugin_fct);
dc8c34
             }
dc8c34
             plugin_flag = 1;
dc8c34
         }
dc8c34
@@ -1325,21 +1329,20 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor
dc8c34
                 slapi_entry_attr_find(entryAfter,
dc8c34
                              "nsslapd-distribution-plugin", &attr);
dc8c34
                 slapi_attr_first_value(attr, &val;;
dc8c34
+                slapi_ch_free_string(&plugin_lib);
dc8c34
                 if (NULL == val) {
dc8c34
                     LDAPDebug(LDAP_DEBUG_ANY,
dc8c34
                         "Warning: The nsslapd-distribution-plugin attribute"
dc8c34
                         " has no value for the mapping tree node %s\n",
dc8c34
                     slapi_entry_get_dn(entryAfter), 0, 0);
dc8c34
-                    plugin_lib = NULL;
dc8c34
                 }
dc8c34
                 plugin_lib = slapi_ch_strdup(slapi_value_get_string(val));
dc8c34
             }
dc8c34
             else if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op))
dc8c34
             {
dc8c34
-                plugin_lib = NULL;
dc8c34
+                slapi_ch_free_string(&plugin_lib);
dc8c34
             }
dc8c34
             plugin_flag = 1;
dc8c34
-
dc8c34
         }
dc8c34
     }
dc8c34
 
dc8c34
diff --git a/lib/ldaputil/certmap.c b/lib/ldaputil/certmap.c
dc8c34
index 0935e4d..e656e20 100644
dc8c34
--- a/lib/ldaputil/certmap.c
dc8c34
+++ b/lib/ldaputil/certmap.c
dc8c34
@@ -737,7 +737,9 @@ static int ldapu_cert_searchfn_default (void *cert, LDAP *ld,
dc8c34
 
dc8c34
 	rv = ldapu_get_cert_subject_dn(cert, &subjectDN);
dc8c34
 
dc8c34
-	if (rv != LDAPU_SUCCESS || !subjectDN || !*subjectDN) return rv;
dc8c34
+	if (rv != LDAPU_SUCCESS || !subjectDN){
dc8c34
+		return rv;
dc8c34
+	}
dc8c34
 	len = strlen(certmap_info->searchAttr) + strlen(subjectDN) +
dc8c34
 	    strlen("=") + 1;
dc8c34
 	certFilter = (char *)ldapu_malloc(len * sizeof(char));
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34