Blob Blame History Raw
From 34412b2d90f324b178166af3ac852b4581f8493a Mon Sep 17 00:00:00 2001
From: Alexey Tikhonov <atikhono@redhat.com>
Date: Mon, 28 Jan 2019 18:47:27 +0100
Subject: [PATCH 3/9] providers/proxy: fixed usage of wrong mem ctx
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Temporary var `grp` in proxy_id.c:remove_duplicate_group_members()
should be created in `tmp_ctx`.
Call to
```
*_grp = talloc_steal(mem_ctx, grp);
```
as well confirms it was original intent
(before fix this call didn't have any sense).

Having `grp` created in `mem_ctx` may lead to memory leak in case
of failure. While actually this doesn't happen since caller of
remove_duplicate_group_members() cleans mem_ctx, still it is
good to fix it.

Reviewed-by: Pavel Březina <pbrezina@redhat.com>
(cherry picked from commit cc9f0f419b4c6bcd7f1a4d9f6ed45c89a33de9dc)

Reviewed-by: Pavel Březina <pbrezina@redhat.com>
---
 src/providers/proxy/proxy_id.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/providers/proxy/proxy_id.c b/src/providers/proxy/proxy_id.c
index db65a984c..52f7a6424 100644
--- a/src/providers/proxy/proxy_id.c
+++ b/src/providers/proxy/proxy_id.c
@@ -649,7 +649,7 @@ static errno_t remove_duplicate_group_members(TALLOC_CTX *mem_ctx,
         goto done;
     }
 
-    grp = talloc(mem_ctx, struct group);
+    grp = talloc(tmp_ctx, struct group);
     if (grp == NULL) {
         DEBUG(SSSDBG_OP_FAILURE, "talloc failed.\n");
         ret = ENOMEM;
-- 
2.21.1