diff options
author | Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de> | 2008-09-18 16:51:48 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-10-21 14:40:41 +0200 |
commit | 47868196b8f989492e0e5c47f384a713791be683 (patch) | |
tree | e4f9b202dfdeec7ecb4b3ef32fc422ec7569f74a | |
parent | 2a267e6da524c5dc69b3e2d97114f17461567856 (diff) | |
download | samba-47868196b8f989492e0e5c47f384a713791be683.tar.gz samba-47868196b8f989492e0e5c47f384a713791be683.tar.bz2 samba-47868196b8f989492e0e5c47f384a713791be683.zip |
Registry server LDB backend REG_SZ type: Fix up the empty string problem
This fixes up the empty string problem in a better way without the need of changing the character conversion code.
-rw-r--r-- | source4/lib/registry/ldb.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c index 8d02b3ce02..386da2b12c 100644 --- a/source4/lib/registry/ldb.c +++ b/source4/lib/registry/ldb.c @@ -60,13 +60,18 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, { case REG_SZ: case REG_EXPAND_SZ: - data->length = convert_string_talloc(mem_ctx, iconv_convenience, CH_UNIX, CH_UTF16, + if (val != NULL) + data->length = convert_string_talloc(mem_ctx, iconv_convenience, CH_UNIX, CH_UTF16, val->data, val->length, (void **)&data->data); + else { + data->data = NULL; + data->length = 0; + } break; case REG_BINARY: - if (val) + if (val != NULL) *data = strhex_to_data_blob((char *)val->data); else { data->data = NULL; @@ -100,11 +105,15 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx, switch (type) { case REG_SZ: case REG_EXPAND_SZ: - val.length = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, + if (data.data[0] != '\0') { + val.length = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, (void *)data.data, data.length, (void **)&val.data); - ldb_msg_add_value(msg, "data", &val, NULL); + ldb_msg_add_value(msg, "data", &val, NULL); + } else { + ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL); + } break; case REG_BINARY: @@ -704,7 +713,8 @@ static WERROR ldb_set_value(struct hive_key *parent, if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) { int i; for (i = 0; i < msg->num_elements; i++) { - msg->elements[i].flags = LDB_FLAG_MOD_REPLACE; + if (msg->elements[i].flags != LDB_FLAG_MOD_DELETE) + msg->elements[i].flags = LDB_FLAG_MOD_REPLACE; } ret = ldb_modify(kd->ldb, msg); } |