zrhoffman / rpms / 389-ds-base

Forked from rpms/389-ds-base 3 years ago
Clone
Blob Blame History Raw
From 476ffd9a01ac5bb55d32edad64c68eebd8773861 Mon Sep 17 00:00:00 2001
From: Mark Reynolds <mreynolds@redhat.com>
Date: Mon, 10 Aug 2015 10:42:40 -0400
Subject: [PATCH 82/84] 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)
(cherry picked from commit a389bc3bafccb1f7bd9917a734230680e382af91)
---
 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 5fc1314..c335cab 100644
--- a/ldap/servers/plugins/memberof/memberof_config.c
+++ b/ldap/servers/plugins/memberof/memberof_config.c
@@ -335,6 +335,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;
@@ -360,8 +361,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;
 			}
@@ -747,7 +749,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