andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From 2f960e4bd658679330faa249981f1b48bc7a6e03 Mon Sep 17 00:00:00 2001
dc8c34
From: Noriko Hosoi <nhosoi@totoro.usersys.redhat.com>
dc8c34
Date: Wed, 24 Oct 2012 15:27:48 -0700
dc8c34
Subject: [PATCH 06/10] Coverity defects
dc8c34
dc8c34
The commit b9eeb2e1a8e688dfec753e8965d0e5aeb119e638 for Ticket #481
dc8c34
"expand nested posix groups" introduced 4 coverity defects.
dc8c34
dc8c34
Description:
dc8c34
13100, 13101: Missing return statement
dc8c34
Fix description: addUserToGroupMembership and propogateDeletion-
dc8c34
UpwardCallback are declared to return an integer value, but
dc8c34
nothing was returned.  This patch changes it to return 0.
dc8c34
dc8c34
13102: Resource leak
dc8c34
Fix description: The memory of valueset muid_old_vs is internally
dc8c34
allocated.  It was meant to be set to muid_upward_vs and freed
dc8c34
together when muid_upward_vs is freed.  But due to the function
dc8c34
calling order, it was not properly set and it lost the chance to
dc8c34
be freed.  This patch calls slapi_attr_get_valueset prior to
dc8c34
slapi_valueset_set_valueset and let free muid_old_vs together
dc8c34
with slapi_valueset_set_valueset.
dc8c34
dc8c34
13103: Uninitialized pointer read
dc8c34
Fix description: Possibly uninitialized variable was passed to
dc8c34
a logging function slapi_log_error, but actually it was not
dc8c34
referred.  With this patch, the variable filter is no longer to
dc8c34
passed to the function.
dc8c34
(cherry picked from commit e9941a2915ac848abe9a4afe802d0432aa0c354a)
dc8c34
(cherry picked from commit a57d9131f9d0ae7a5d9865dd6be7f37f26de376c)
dc8c34
---
dc8c34
 .../plugins/posix-winsync/posix-group-func.c       |    8 +++++---
dc8c34
 .../plugins/posix-winsync/posix-group-task.c       |    4 ++--
dc8c34
 2 files changed, 7 insertions(+), 5 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/plugins/posix-winsync/posix-group-func.c b/ldap/servers/plugins/posix-winsync/posix-group-func.c
dc8c34
index 66b9272..be3a6ec 100644
dc8c34
--- a/ldap/servers/plugins/posix-winsync/posix-group-func.c
dc8c34
+++ b/ldap/servers/plugins/posix-winsync/posix-group-func.c
dc8c34
@@ -473,15 +473,15 @@ propogateMembershipUpward(Slapi_Entry *entry, Slapi_ValueSet *muid_vs, int depth
dc8c34
             muid_here_vs = muid_vs;
dc8c34
         }
dc8c34
         else {
dc8c34
+            int i = 0;
dc8c34
+            Slapi_Value *v = NULL;
dc8c34
             /* Eliminate duplicates */
dc8c34
             muid_upward_vs = slapi_valueset_new();
dc8c34
             muid_here_vs = slapi_valueset_new();
dc8c34
 
dc8c34
+            slapi_attr_get_valueset(muid_old_attr, &muid_old_vs);
dc8c34
             slapi_valueset_set_valueset(muid_upward_vs, muid_old_vs);
dc8c34
 
dc8c34
-            slapi_attr_get_valueset(muid_old_attr, &muid_old_vs);
dc8c34
-            int i = 0;
dc8c34
-            Slapi_Value *v = NULL;
dc8c34
             for (i = slapi_valueset_first_value(muid_vs, &v); i != -1;
dc8c34
                  i = slapi_valueset_next_value(muid_vs, i, &v)) {
dc8c34
                 
dc8c34
@@ -542,6 +542,7 @@ propogateDeletionsUpwardCallback(Slapi_Entry *entry, void *callback_data)
dc8c34
 {
dc8c34
     struct propogateDeletionsUpwardArgs *args = (struct propogateDeletionsUpwardArgs *)(callback_data);
dc8c34
     propogateDeletionsUpward(entry, args->base_sdn, args->smod_deluids, args->del_nested_vs, args->depth);
dc8c34
+    return 0;
dc8c34
 }
dc8c34
 
dc8c34
 void
dc8c34
@@ -920,6 +921,7 @@ addUserToGroupMembership(Slapi_Entry *entry)
dc8c34
     propogateMembershipUpward(entry, muid_vs, 0);
dc8c34
 
dc8c34
     slapi_valueset_free(muid_vs); muid_vs = NULL;
dc8c34
+    return 0;
dc8c34
 }
dc8c34
 
dc8c34
 int
dc8c34
diff --git a/ldap/servers/plugins/posix-winsync/posix-group-task.c b/ldap/servers/plugins/posix-winsync/posix-group-task.c
dc8c34
index 4555f1b..e5385b0 100644
dc8c34
--- a/ldap/servers/plugins/posix-winsync/posix-group-task.c
dc8c34
+++ b/ldap/servers/plugins/posix-winsync/posix-group-task.c
dc8c34
@@ -152,9 +152,9 @@ posix_group_task_add(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *eAfter, int
dc8c34
         rv = SLAPI_DSE_CALLBACK_OK;
dc8c34
     }
dc8c34
 
dc8c34
-    out: 
dc8c34
+out: 
dc8c34
     slapi_log_error(SLAPI_LOG_PLUGIN, POSIX_WINSYNC_PLUGIN_NAME,
dc8c34
-                    "posix_group_task_add: <==\n", filter);
dc8c34
+                    "posix_group_task_add: <==\n");
dc8c34
 
dc8c34
     return rv;
dc8c34
 }
dc8c34
-- 
dc8c34
1.7.1
dc8c34