File 140619-SYSDB-sysdb_search_custom-fix-memory-leak.patch of Package sssd.openSUSE_Leap_42.1_Update

From 8488fbadeba254a989a3ed703c12abc8cc83f6d1 Mon Sep 17 00:00:00 2001
From: Pavel Reichl <preichl@redhat.com>
Date: Thu, 19 Jun 2014 12:23:26 +0100
Subject: [PATCH] SYSDB: sysdb_search_custom fix memory leak

Add temporally talloc context to allocate basedn on.

Reviewed-by: Stephen Gallagher <sgallagh@redhat.com>
(cherry picked from commit a4caef931a245fb3c44b70ea65a58bd0c1ff8dc4)

diff -rupN sssd-1.11.5.1-original/src/db/sysdb_ops.c sssd-1.11.5.1-patched/src/db/sysdb_ops.c
--- sssd-1.11.5.1-original/src/db/sysdb_ops.c	2017-01-30 13:59:28.041155212 +0100
+++ sssd-1.11.5.1-patched/src/db/sysdb_ops.c	2017-01-30 14:07:38.758713303 +0100
@@ -2149,26 +2149,38 @@ int sysdb_search_custom(TALLOC_CTX *mem_
                         size_t *msgs_count,
                         struct ldb_message ***msgs)
 {
-    struct ldb_dn *basedn;
+    TALLOC_CTX *tmp_ctx;
+    struct ldb_dn *basedn = NULL;
     int ret;
 
+    tmp_ctx = talloc_new(NULL);
+    if (tmp_ctx == NULL) {
+        ret = ENOMEM;
+        goto done;
+    }
+
     if (filter == NULL || subtree_name == NULL) {
-        return EINVAL;
+        ret = EINVAL;
+        goto done;
     }
 
-    basedn = sysdb_custom_subtree_dn(sysdb, mem_ctx, domain, subtree_name);
+    basedn = sysdb_custom_subtree_dn(sysdb, tmp_ctx, domain, subtree_name);
     if (basedn == NULL) {
         DEBUG(1, ("sysdb_custom_subtree_dn failed.\n"));
-        return ENOMEM;
+        ret = ENOMEM;
+        goto done;
     }
     if (!ldb_dn_validate(basedn)) {
         DEBUG(1, ("Failed to create DN.\n"));
-        return EINVAL;
+        ret = EINVAL;
+        goto done;
     }
 
     ret = sysdb_search_entry(mem_ctx, sysdb, basedn,
                              LDB_SCOPE_SUBTREE, filter, attrs,
                              msgs_count, msgs);
+done:
+    talloc_free(tmp_ctx);
     return ret;
 }
 
Binary files sssd-1.11.5.1-original/src/db/.sysdb_ops.c.rej.swp and sssd-1.11.5.1-patched/src/db/.sysdb_ops.c.rej.swp differ