Blame SOURCES/0109-memberof-Don-t-allocate-on-a-NULL-context.patch

3203b4
From 50d5d5c2b8b304234b222c76413c47dc31a6379f Mon Sep 17 00:00:00 2001
3203b4
From: Jakub Hrozek <jhrozek@redhat.com>
3203b4
Date: Fri, 19 Feb 2016 15:50:12 +0100
3203b4
Subject: [PATCH 109/109] memberof: Don't allocate on a NULL context
3203b4
MIME-Version: 1.0
3203b4
Content-Type: text/plain; charset=UTF-8
3203b4
Content-Transfer-Encoding: 8bit
3203b4
3203b4
https://fedorahosted.org/sssd/ticket/2959
3203b4
3203b4
In case no previous delete operation occured, the del_ctx->muops pointer we
3203b4
allocate the diff structure was would be NULL, effectivelly leaking the
3203b4
diff array during the memberof processing.
3203b4
3203b4
Allocating on del_ctx is safer as that pointer is always allocated and
3203b4
prevents the leak.
3203b4
3203b4
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
3203b4
(cherry picked from commit cd7a272fb361626a45d54cd45daaab4bfe7ad93f)
3203b4
---
3203b4
 src/ldb_modules/memberof.c | 3 ++-
3203b4
 1 file changed, 2 insertions(+), 1 deletion(-)
3203b4
3203b4
diff --git a/src/ldb_modules/memberof.c b/src/ldb_modules/memberof.c
3203b4
index 4d7b23ea1b95bed0ec5c7cc717b95e6da3cd0717..be7c07dbcda257b6d813bb232ec27973167c25c4 100644
3203b4
--- a/src/ldb_modules/memberof.c
3203b4
+++ b/src/ldb_modules/memberof.c
3203b4
@@ -2145,7 +2145,7 @@ static int mbof_del_mod_entry(struct mbof_del_operation *delop)
3203b4
         if (!el || !el->num_values) {
3203b4
             return LDB_ERR_OPERATIONS_ERROR;
3203b4
         }
3203b4
-        diff = talloc_array(del_ctx->muops, struct ldb_dn *,
3203b4
+        diff = talloc_array(del_ctx, struct ldb_dn *,
3203b4
                             el->num_values + 1);
3203b4
         if (!diff) {
3203b4
             return LDB_ERR_OPERATIONS_ERROR;
3203b4
@@ -2241,6 +2241,7 @@ static int mbof_del_mod_entry(struct mbof_del_operation *delop)
3203b4
             if (ret != LDB_SUCCESS) {
3203b4
                 return ret;
3203b4
             }
3203b4
+            talloc_steal(del_ctx->muops, diff[i]);
3203b4
         }
3203b4
     }
3203b4
 
3203b4
-- 
3203b4
2.4.11
3203b4