s4:registry - "reg_ldb_pack_value" - provide workarounds when the server receives...
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Tue, 23 Mar 2010 15:19:26 +0000 (16:19 +0100)
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Tue, 23 Mar 2010 15:46:17 +0000 (16:46 +0100)
For now we reset/delete the "data" attribute. Anyway there is the need to find
a better solution (we probably want to change the format and save all data as
we got it like Windows itself does).

These workarounds are needed since for example the Windows 2000 Registry Editor
initialises empty REG_SZ strings with content '\0' and length 1 (not a valid
UTF16 sequence - "convert_string_talloc" breaks). So we simply reset/delete the
"data" attribute which works (no content).

source4/lib/registry/ldb.c

index 9b834faa987abebd6443eef97a2f06008e31dd3d..b897641f33d96c6f3ec15b0667a3ce82b52bd145 100644 (file)
@@ -162,6 +162,9 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
                                                     false);
                        if (ret2) {
                                ret = ldb_msg_add_value(msg, "data", val, NULL);
+                       } else {
+                               /* workaround for non-standard data */
+                               ret = ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL);
                        }
                } else {
                        ret = ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL);
@@ -181,6 +184,9 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
                                        return NULL;
                                }
                                ret = ldb_msg_add_string(msg, "data", conv_str);
+                       } else {
+                               /* workaround for non-standard data */
+                               ret = ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL);
                        }
                } else {
                        ret = ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL);
@@ -199,6 +205,9 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
                                        return NULL;
                                }
                                ret = ldb_msg_add_string(msg, "data", conv_str);
+                       } else {
+                               /* workaround for non-standard data */
+                               ret = ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL);
                        }
                } else {
                        ret = ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL);