Blame SOURCES/0103-AD-do-not-allocate-temporary-data-on-long-living-con.patch

ced1f5
From 3dae415229a7a2526a886ea55a12377fdc62361e Mon Sep 17 00:00:00 2001
ced1f5
From: Sumit Bose <sbose@redhat.com>
ced1f5
Date: Fri, 16 Feb 2018 12:09:01 +0100
ced1f5
Subject: [PATCH] AD: do not allocate temporary data on long living context
ced1f5
ced1f5
Related to https://pagure.io/SSSD/sssd/issue/3639
ced1f5
ced1f5
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
ced1f5
(cherry picked from commit e6ad16e05f42a1678a8c6cd14eb54ca75b8d775e)
ced1f5
---
ced1f5
 src/providers/ad/ad_common.c      | 5 +++--
ced1f5
 src/providers/ad/ad_common.h      | 3 ++-
ced1f5
 src/providers/ad/ad_id.c          | 2 +-
ced1f5
 src/tests/cmocka/test_ad_common.c | 4 ++--
ced1f5
 4 files changed, 8 insertions(+), 6 deletions(-)
ced1f5
ced1f5
diff --git a/src/providers/ad/ad_common.c b/src/providers/ad/ad_common.c
ced1f5
index 84845e285bef336b503b9d27bfc6eb99d6ee43ff..2a1647173b76b410371315eb364e9a3785714a93 100644
ced1f5
--- a/src/providers/ad/ad_common.c
ced1f5
+++ b/src/providers/ad/ad_common.c
ced1f5
@@ -1402,13 +1402,14 @@ ad_ldap_conn_list(TALLOC_CTX *mem_ctx,
ced1f5
 }
ced1f5
 
ced1f5
 struct sdap_id_conn_ctx **
ced1f5
-ad_user_conn_list(struct ad_id_ctx *ad_ctx,
ced1f5
+ad_user_conn_list(TALLOC_CTX *mem_ctx,
ced1f5
+                  struct ad_id_ctx *ad_ctx,
ced1f5
                   struct sss_domain_info *dom)
ced1f5
 {
ced1f5
     struct sdap_id_conn_ctx **clist;
ced1f5
     int cindex = 0;
ced1f5
 
ced1f5
-    clist = talloc_zero_array(ad_ctx, struct sdap_id_conn_ctx *, 3);
ced1f5
+    clist = talloc_zero_array(mem_ctx, struct sdap_id_conn_ctx *, 3);
ced1f5
     if (clist == NULL) {
ced1f5
         return NULL;
ced1f5
     }
ced1f5
diff --git a/src/providers/ad/ad_common.h b/src/providers/ad/ad_common.h
ced1f5
index ce33b37c75f45ae72adb268858cce34759b8b02f..931aafc6c031e0979460925a1402517b054b202c 100644
ced1f5
--- a/src/providers/ad/ad_common.h
ced1f5
+++ b/src/providers/ad/ad_common.h
ced1f5
@@ -175,7 +175,8 @@ ad_ldap_conn_list(TALLOC_CTX *mem_ctx,
ced1f5
                   struct sss_domain_info *dom);
ced1f5
 
ced1f5
 struct sdap_id_conn_ctx **
ced1f5
-ad_user_conn_list(struct ad_id_ctx *ad_ctx,
ced1f5
+ad_user_conn_list(TALLOC_CTX *mem_ctx,
ced1f5
+                  struct ad_id_ctx *ad_ctx,
ced1f5
                   struct sss_domain_info *dom);
ced1f5
 
ced1f5
 struct sdap_id_conn_ctx *
ced1f5
diff --git a/src/providers/ad/ad_id.c b/src/providers/ad/ad_id.c
ced1f5
index 0b8f49819405c7dbbfa18b5359f7743441dc65e5..782d9bc402e71d6b20976367f6afbae82bd25750 100644
ced1f5
--- a/src/providers/ad/ad_id.c
ced1f5
+++ b/src/providers/ad/ad_id.c
ced1f5
@@ -367,7 +367,7 @@ get_conn_list(TALLOC_CTX *mem_ctx, struct ad_id_ctx *ad_ctx,
ced1f5
 
ced1f5
     switch (ar->entry_type & BE_REQ_TYPE_MASK) {
ced1f5
     case BE_REQ_USER: /* user */
ced1f5
-        clist = ad_user_conn_list(ad_ctx, dom);
ced1f5
+        clist = ad_user_conn_list(mem_ctx, ad_ctx, dom);
ced1f5
         break;
ced1f5
     case BE_REQ_BY_SECID:   /* by SID */
ced1f5
     case BE_REQ_USER_AND_GROUP: /* get SID */
ced1f5
diff --git a/src/tests/cmocka/test_ad_common.c b/src/tests/cmocka/test_ad_common.c
ced1f5
index 80b3bb5599a95578b7734d5dfcd20a2a7428a084..a8a447e91bd5107bbfc9d8445d0508778a5012f8 100644
ced1f5
--- a/src/tests/cmocka/test_ad_common.c
ced1f5
+++ b/src/tests/cmocka/test_ad_common.c
ced1f5
@@ -771,7 +771,7 @@ void test_user_conn_list(void **state)
ced1f5
                                                      struct ad_common_test_ctx);
ced1f5
     assert_non_null(test_ctx);
ced1f5
 
ced1f5
-    conn_list = ad_user_conn_list(test_ctx->ad_ctx,
ced1f5
+    conn_list = ad_user_conn_list(test_ctx, test_ctx->ad_ctx,
ced1f5
                                   test_ctx->dom);
ced1f5
     assert_non_null(conn_list);
ced1f5
 
ced1f5
@@ -780,7 +780,7 @@ void test_user_conn_list(void **state)
ced1f5
     assert_null(conn_list[1]);
ced1f5
     talloc_free(conn_list);
ced1f5
 
ced1f5
-    conn_list = ad_user_conn_list(test_ctx->ad_ctx,
ced1f5
+    conn_list = ad_user_conn_list(test_ctx, test_ctx->ad_ctx,
ced1f5
                                   test_ctx->subdom);
ced1f5
     assert_non_null(conn_list);
ced1f5
 
ced1f5
-- 
ced1f5
2.14.3
ced1f5