summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/db/sysdb.c10
-rw-r--r--src/db/sysdb.h2
-rw-r--r--src/providers/ldap/sdap.c8
-rw-r--r--src/providers/ldap/sdap_async.c4
4 files changed, 17 insertions, 7 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index e7524f4b..7c347912 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -512,6 +512,16 @@ int sysdb_attrs_add_string(struct sysdb_attrs *attrs,
return sysdb_attrs_add_val(attrs, name, &v);
}
+int sysdb_attrs_add_mem(struct sysdb_attrs *attrs, const char *name,
+ const void *mem, size_t size)
+{
+ struct ldb_val v;
+
+ v.data = discard_const(mem);
+ v.length = size;
+ return sysdb_attrs_add_val(attrs, name, &v);
+}
+
int sysdb_attrs_add_bool(struct sysdb_attrs *attrs,
const char *name, bool value)
{
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index fff97a8a..23cbbb0d 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -250,6 +250,8 @@ int sysdb_attrs_add_val(struct sysdb_attrs *attrs,
const char *name, const struct ldb_val *val);
int sysdb_attrs_add_string(struct sysdb_attrs *attrs,
const char *name, const char *str);
+int sysdb_attrs_add_mem(struct sysdb_attrs *, const char *,
+ const void *, size_t);
int sysdb_attrs_add_bool(struct sysdb_attrs *attrs,
const char *name, bool value);
int sysdb_attrs_add_long(struct sysdb_attrs *attrs,
diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c
index 371121b2..dba4e41d 100644
--- a/src/providers/ldap/sdap.c
+++ b/src/providers/ldap/sdap.c
@@ -343,7 +343,6 @@ errno_t sdap_parse_deref(TALLOC_CTX *mem_ctx,
const char **ocs;
struct sdap_attr_map *map;
int num_attrs;
- struct ldb_val v;
int ret, i, a, mi;
const char *name;
size_t len;
@@ -474,10 +473,9 @@ errno_t sdap_parse_deref(TALLOC_CTX *mem_ctx,
for (i=0; dval->vals[i].bv_val; i++) {
DEBUG(9, ("Dereferenced attribute value: %s\n",
dval->vals[i].bv_val));
- v.data = (uint8_t *) dval->vals[i].bv_val;
- v.length = dval->vals[i].bv_len;
-
- ret = sysdb_attrs_add_val(res[mi]->attrs, name, &v);
+ ret = sysdb_attrs_add_mem(res[mi]->attrs, name,
+ dval->vals[i].bv_val,
+ dval->vals[i].bv_len);
if (ret) goto done;
}
}
diff --git a/src/providers/ldap/sdap_async.c b/src/providers/ldap/sdap_async.c
index 84497b75..b7d98392 100644
--- a/src/providers/ldap/sdap_async.c
+++ b/src/providers/ldap/sdap_async.c
@@ -2226,8 +2226,8 @@ sdap_attrs_add_ldap_attr(struct sysdb_attrs *ldap_attrs,
DEBUG(SSSDBG_TRACE_INTERNAL, ("Adding %s [%s] to attributes "
"of [%s].\n", desc, el->values[i].data, objname));
- ret = sysdb_attrs_add_string(attrs, attr_name,
- (const char *) el->values[i].data);
+ ret = sysdb_attrs_add_mem(attrs, attr_name, el->values[i].data,
+ el->values[i].length);
if (ret) {
return ret;
}