File 0010-Fix-segfault-in-sss_cache.patch of Package sssd.openSUSE_Leap_42.1_Update

The patch is authored by Roberto Sassu (rsassu@suse.com) on 2016-04-19.
It is a very simple and straight forward fix for a segmentation fault
that happens when sss_cache is called with a specified domain name.
The upstream patch for the issue is more complicated as it comprises
some refactoring effort.

--- sssd-1.11.5.1/src/confdb/confdb.c   
+++ sssd-1.11.5.1-patched/src/confdb/confdb.c   
@@ -1157,8 +1157,9 @@ done:
     return ret;
 }
 
-int confdb_get_domains(struct confdb_ctx *cdb,
-                       struct sss_domain_info **domains)
+static int confdb_get_domains_common(struct confdb_ctx *cdb,
+                                     const char *domain_name,
+                                     struct sss_domain_info **domains)
 {
     TALLOC_CTX *tmp_ctx;
     struct sss_domain_info *domain = NULL;
@@ -1187,6 +1188,10 @@ int confdb_get_domains(struct confdb_ctx
     }
 
     for (i = 0; domlist[i]; i++) {
+        /* If the user specified a domain, initialize only this one. */
+        if (domain_name && strcasecmp(domlist[i], domain_name) != 0)
+            continue;
+
         ret = confdb_get_domain_internal(cdb, cdb, domlist[i], &domain);
         if (ret) {
             DEBUG(0, ("Error (%d [%s]) retrieving domain [%s], skipping!\n",
@@ -1211,24 +1216,15 @@ done:
     return ret;
 }
 
+int confdb_get_domains(struct confdb_ctx *cdb,
+                       struct sss_domain_info **domains)
+{
+    return confdb_get_domains_common(cdb, NULL, domains);
+}
+
 int confdb_get_domain(struct confdb_ctx *cdb,
                       const char *name,
                       struct sss_domain_info **_domain)
 {
-    struct sss_domain_info *dom, *doms;
-    int ret;
-
-    ret = confdb_get_domains(cdb, &doms);
-    if (ret != EOK) {
-        return ret;
-    }
-
-    for (dom = doms; dom; dom = get_next_domain(dom, false)) {
-        if (strcasecmp(dom->name, name) == 0) {
-            *_domain = dom;
-            return EOK;
-        }
-    }
-
-    return ENOENT;
+    return confdb_get_domains_common(cdb, name, _domain);
 }