summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/common/ldb_dn.c2
-rw-r--r--source4/lib/ldb/include/ldb.h1
-rw-r--r--source4/lib/registry/reg_backend_ldb.c18
3 files changed, 17 insertions, 4 deletions
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index 5dcb540fa1..d13238cc17 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -56,7 +56,7 @@ static int ldb_dn_is_valid_attribute_name(const char *name)
return 1;
}
-static char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value)
+char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value)
{
const char *p, *s, *src;
char *d, *dst;
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 7399b8ffe7..fdf5dc8d91 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -342,6 +342,7 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb,
int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2);
int ldb_attr_cmp(const char *dn1, const char *dn2);
+char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value);
/* case-fold a DN */
char *ldb_dn_fold(void * mem_ctx,
diff --git a/source4/lib/registry/reg_backend_ldb.c b/source4/lib/registry/reg_backend_ldb.c
index 784d8ac6fa..114614597f 100644
--- a/source4/lib/registry/reg_backend_ldb.c
+++ b/source4/lib/registry/reg_backend_ldb.c
@@ -126,12 +126,24 @@ static char *reg_path_to_ldb(TALLOC_CTX *mem_ctx, struct registry_key *from, con
while(mypath) {
char *keyname;
begin = strrchr(mypath, '\\');
+ struct ldb_val val;
+ char *key;
- if(begin) keyname = begin + 1;
+ if (begin) keyname = begin + 1;
else keyname = mypath;
- if(strlen(keyname))
- ret = talloc_asprintf_append(ret, "key=%s,", keyname);
+ val.data = keyname;
+ val.length = strlen(keyname);
+
+ key = ldb_dn_escape_value(mem_ctx, val);
+ if (key == NULL) {
+ return NULL;
+ }
+
+ if (strlen(key))
+ ret = talloc_asprintf_append(ret, "key=%s,", key);
+
+ talloc_free(key);
if(begin) {
*begin = '\0';