From 0eb62fc11bfd2bbdc9cb8e711945b3ed2b590e48 Mon Sep 17 00:00:00 2001
From: Alexey Tikhonov <atikhono@redhat.com>
Date: Wed, 6 Feb 2019 13:59:22 +0100
Subject: [PATCH 1/2] providers/ldap: sdap_extend_map_with_list() fixed

Changed sdap_extend_map_with_list() to return src_map in case
of fail thus making behaviour consistent with sdap_extend_map()
---
 src/providers/ldap/sdap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c
index 5c9d0a45df..b5d7d424c0 100644
--- a/src/providers/ldap/sdap.c
+++ b/src/providers/ldap/sdap.c
@@ -238,9 +238,9 @@ int sdap_extend_map_with_list(TALLOC_CTX *mem_ctx,
     char **extra_attrs_list;
     errno_t ret;
 
+    *_map = src_map;
     extra_attrs = dp_opt_get_string(opts->basic, extra_attr_index);
     if (extra_attrs == NULL) {
-        *_map = src_map;
         *_new_size = num_entries;
         return EOK;
     }

From b30f04ce5500ab14be631fd6d28b72ebf8462ad6 Mon Sep 17 00:00:00 2001
From: Alexey Tikhonov <atikhono@redhat.com>
Date: Wed, 6 Feb 2019 15:03:15 +0100
Subject: [PATCH 2/2] providers/ldap: const params should be const

Not intended to be changed params are marked as pointer to const data.
---
 src/providers/ldap/sdap.c | 10 ++++------
 src/providers/ldap/sdap.h |  2 +-
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c
index b5d7d424c0..968f9fef14 100644
--- a/src/providers/ldap/sdap.c
+++ b/src/providers/ldap/sdap.c
@@ -89,7 +89,7 @@ int sdap_copy_map(TALLOC_CTX *memctx,
 }
 
 static errno_t split_extra_attr(TALLOC_CTX *mem_ctx,
-                                char *conf_attr,
+                                const char *conf_attr,
                                 char **_sysdb_attr,
                                 char **_ldap_attr)
 {
@@ -97,8 +97,6 @@ static errno_t split_extra_attr(TALLOC_CTX *mem_ctx,
     char *sysdb_attr;
     char *sep;
 
-    ldap_attr = conf_attr;
-
     sep = strchr(conf_attr, ':');
     if (sep == NULL) {
         sysdb_attr = talloc_strdup(mem_ctx, conf_attr);
@@ -108,8 +106,8 @@ static errno_t split_extra_attr(TALLOC_CTX *mem_ctx,
             return ERR_INVALID_EXTRA_ATTR;
         }
 
-        sysdb_attr = talloc_strndup(mem_ctx, ldap_attr,
-                                    sep - ldap_attr);
+        sysdb_attr = talloc_strndup(mem_ctx, conf_attr,
+                                    sep - conf_attr);
         ldap_attr = talloc_strdup(mem_ctx, sep+1);
     }
 
@@ -227,7 +225,7 @@ int sdap_extend_map(TALLOC_CTX *memctx,
 }
 
 int sdap_extend_map_with_list(TALLOC_CTX *mem_ctx,
-                              struct sdap_options *opts,
+                              const struct sdap_options *opts,
                               int extra_attr_index,
                               struct sdap_attr_map *src_map,
                               size_t num_entries,
diff --git a/src/providers/ldap/sdap.h b/src/providers/ldap/sdap.h
index b1ea3f0b57..0fa3b57b7c 100644
--- a/src/providers/ldap/sdap.h
+++ b/src/providers/ldap/sdap.h
@@ -564,7 +564,7 @@ int sdap_extend_map(TALLOC_CTX *memctx,
                     size_t *_new_size);
 
 int sdap_extend_map_with_list(TALLOC_CTX *mem_ctx,
-                              struct sdap_options *opts,
+                              const struct sdap_options *opts,
                               int extra_attr_index,
                               struct sdap_attr_map *src_map,
                               size_t num_entries,
