}
+static char *reg_ldb_escape(TALLOC_CTX *mem_ctx, const char *value)
+{
+ struct ldb_val val;
+
+ val.data = discard_const_p(uint8_t, value);
+ val.length = strlen(value);
+
+ return ldb_dn_escape_value(mem_ctx, val);
+}
+
static int reg_close_ldb_key(struct ldb_key_data *key)
{
if (key->subkeys != NULL) {
struct ldb_dn *childdn;
childdn = ldb_dn_copy(kd->ldb, kd->dn);
- ldb_dn_add_child_fmt(childdn, "value=%s", child);
+ if (!ldb_dn_add_child_fmt(childdn, "value=%s",
+ reg_ldb_escape(childdn, child)))
+ {
+ talloc_free(childdn);
+ return WERR_FOOBAR;
+ }
ret = ldb_delete(kd->ldb, childdn);
msg = reg_ldb_pack_value(kd->ldb, mem_ctx, name, type, data);
msg->dn = ldb_dn_copy(msg, kd->dn);
- ldb_dn_add_child_fmt(msg->dn, "value=%s", name);
+ if (!ldb_dn_add_child_fmt(msg->dn, "value=%s",
+ reg_ldb_escape(mem_ctx, name)))
+ {
+ talloc_free(mem_ctx);
+ return WERR_FOOBAR;
+ }
ret = ldb_add(kd->ldb, msg);
if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) {
&value_type, &value_data);
if (!W_ERROR_IS_OK(result)) {
- return result;
+ /*
+ * Windows expects WERR_BADFILE when a particular value
+ * is not found. If we receive WERR_NOT_FOUND from the lower
+ * layer calls, translate it here to return what is expected.
+ */
+ if (W_ERROR_EQUAL(result, WERR_NOT_FOUND))
+ return WERR_BADFILE;
+ else
+ return result;
}
/* Just asking for the size of the buffer */