a2f18f
From a389bc3bafccb1f7bd9917a734230680e382af91 Mon Sep 17 00:00:00 2001
b161c9
From: Mark Reynolds <mreynolds@redhat.com>
b161c9
Date: Mon, 10 Aug 2015 10:42:40 -0400
a2f18f
Subject: [PATCH] Ticket 47931 - Fix coverity issues
b161c9
b161c9
Description:  Fix coverity issues in memberof_config.c
b161c9
b161c9
              13316 - double free
b161c9
              13315 - Dereference after null check
b161c9
              13314 - Dereference after null check
b161c9
              13313 - copy/paste error
b161c9
b161c9
https://fedorahosted.org/389/ticket/47931
b161c9
b161c9
Reviewed by: rmeggins(Thanks!)
b161c9
b161c9
(cherry picked from commit 5daea973e4526584ee41d7b9f4b1b4993b4de6f1)
b161c9
(cherry picked from commit 9a0047ef75f6dbeb1980ac77fab5d62865c77e6a)
b161c9
---
b161c9
 ldap/servers/plugins/memberof/memberof_config.c | 6 ++++--
b161c9
 1 file changed, 4 insertions(+), 2 deletions(-)
b161c9
b161c9
diff --git a/ldap/servers/plugins/memberof/memberof_config.c b/ldap/servers/plugins/memberof/memberof_config.c
a2f18f
index b4cc941..10cbd7a 100644
b161c9
--- a/ldap/servers/plugins/memberof/memberof_config.c
b161c9
+++ b/ldap/servers/plugins/memberof/memberof_config.c
a2f18f
@@ -316,6 +316,7 @@ memberof_validate_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entr
b161c9
 					"%s: Invalid DN (%s) for include suffix.",
b161c9
 					MEMBEROF_PLUGIN_SUBSYSTEM, entry_scopes[i]);
b161c9
 				slapi_ch_array_free(entry_scopes);
b161c9
+				entry_scopes = NULL;
b161c9
 				theConfig.entryScopeCount = 0;
b161c9
 				*returncode = LDAP_UNWILLING_TO_PERFORM;
b161c9
 				goto done;
a2f18f
@@ -341,8 +342,9 @@ memberof_validate_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entr
b161c9
 				/* invalid dn syntax */
b161c9
 				PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
b161c9
 					"%s: Invalid DN (%s) for exclude suffix.",
b161c9
-					MEMBEROF_PLUGIN_SUBSYSTEM, entry_scopes[i]);
b161c9
+					MEMBEROF_PLUGIN_SUBSYSTEM, entry_exclude_scopes[i]);
b161c9
 				slapi_ch_array_free(entry_exclude_scopes);
b161c9
+				entry_exclude_scopes = NULL;
b161c9
 				*returncode = LDAP_UNWILLING_TO_PERFORM;
b161c9
 				goto done;
b161c9
 			}
a2f18f
@@ -741,7 +743,7 @@ memberof_copy_config(MemberOfConfig *dest, MemberOfConfig *src)
b161c9
 			int num_vals = 0;
b161c9
 
b161c9
 			dest->entryScopeExcludeSubtrees = (Slapi_DN **)slapi_ch_calloc(sizeof(Slapi_DN *),src->entryExcludeScopeCount+1);
b161c9
-			for(num_vals = 0; src->entryScopes[num_vals]; num_vals++){
b161c9
+			for(num_vals = 0; src->entryScopeExcludeSubtrees[num_vals]; num_vals++){
b161c9
 				dest->entryScopeExcludeSubtrees[num_vals] = slapi_sdn_dup(src->entryScopeExcludeSubtrees[num_vals]);
b161c9
 			}
b161c9
 		}
b161c9
-- 
b161c9
1.9.3
b161c9