andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
Blob Blame History Raw
From a389bc3bafccb1f7bd9917a734230680e382af91 Mon Sep 17 00:00:00 2001
From: Mark Reynolds <mreynolds@redhat.com>
Date: Mon, 10 Aug 2015 10:42:40 -0400
Subject: [PATCH] Ticket 47931 - Fix coverity issues

Description:  Fix coverity issues in memberof_config.c

              13316 - double free
              13315 - Dereference after null check
              13314 - Dereference after null check
              13313 - copy/paste error

https://fedorahosted.org/389/ticket/47931

Reviewed by: rmeggins(Thanks!)

(cherry picked from commit 5daea973e4526584ee41d7b9f4b1b4993b4de6f1)
(cherry picked from commit 9a0047ef75f6dbeb1980ac77fab5d62865c77e6a)
---
 ldap/servers/plugins/memberof/memberof_config.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/ldap/servers/plugins/memberof/memberof_config.c b/ldap/servers/plugins/memberof/memberof_config.c
index b4cc941..10cbd7a 100644
--- a/ldap/servers/plugins/memberof/memberof_config.c
+++ b/ldap/servers/plugins/memberof/memberof_config.c
@@ -316,6 +316,7 @@ memberof_validate_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entr
 					"%s: Invalid DN (%s) for include suffix.",
 					MEMBEROF_PLUGIN_SUBSYSTEM, entry_scopes[i]);
 				slapi_ch_array_free(entry_scopes);
+				entry_scopes = NULL;
 				theConfig.entryScopeCount = 0;
 				*returncode = LDAP_UNWILLING_TO_PERFORM;
 				goto done;
@@ -341,8 +342,9 @@ memberof_validate_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entr
 				/* invalid dn syntax */
 				PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
 					"%s: Invalid DN (%s) for exclude suffix.",
-					MEMBEROF_PLUGIN_SUBSYSTEM, entry_scopes[i]);
+					MEMBEROF_PLUGIN_SUBSYSTEM, entry_exclude_scopes[i]);
 				slapi_ch_array_free(entry_exclude_scopes);
+				entry_exclude_scopes = NULL;
 				*returncode = LDAP_UNWILLING_TO_PERFORM;
 				goto done;
 			}
@@ -741,7 +743,7 @@ memberof_copy_config(MemberOfConfig *dest, MemberOfConfig *src)
 			int num_vals = 0;
 
 			dest->entryScopeExcludeSubtrees = (Slapi_DN **)slapi_ch_calloc(sizeof(Slapi_DN *),src->entryExcludeScopeCount+1);
-			for(num_vals = 0; src->entryScopes[num_vals]; num_vals++){
+			for(num_vals = 0; src->entryScopeExcludeSubtrees[num_vals]; num_vals++){
 				dest->entryScopeExcludeSubtrees[num_vals] = slapi_sdn_dup(src->entryScopeExcludeSubtrees[num_vals]);
 			}
 		}
-- 
1.9.3