dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

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

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