s3-registry: use push_reg_sz().
[kai/samba.git] / source3 / registry / reg_backend_db.c
index 7825edd5c252689597911b78c41b326a59a89ac3..b9ff5dc7fc63b8374ebad7591117de34880edd8e 100644 (file)
@@ -2,6 +2,7 @@
  *  Unix SMB/CIFS implementation.
  *  Virtual Windows Registry Layer
  *  Copyright (C) Gerald Carter                     2002-2005
+ *  Copyright (C) Michael Adam                      2007-2009
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -249,7 +250,7 @@ WERROR init_registry_key(const char *add_path)
 static void regdb_ctr_add_value(struct regval_ctr *ctr,
                                struct builtin_regkey_value *value)
 {
-       UNISTR2 data;
+       DATA_BLOB data;
 
        switch(value->type) {
        case REG_DWORD:
@@ -259,10 +260,10 @@ static void regdb_ctr_add_value(struct regval_ctr *ctr,
                break;
 
        case REG_SZ:
-               init_unistr2(&data, value->data.string, UNI_STR_TERMINATE);
+               push_reg_sz(talloc_tos(), &data, value->data.string);
                regval_ctr_addvalue(ctr, value->valuename, REG_SZ,
-                                   (char*)data.buffer,
-                                   data.uni_str_len*sizeof(uint16));
+                                   (char*)data.data,
+                                   data.length);
                break;
 
        default:
@@ -1474,6 +1475,9 @@ static WERROR regdb_fetch_keys_internal(struct db_context *db, const char *key,
        buflen = value.dsize;
        len = tdb_unpack( buf, buflen, "d", &num_items);
 
+       werr = regsubkey_ctr_reinit(ctr);
+       W_ERROR_NOT_OK_GOTO_DONE(werr);
+
        for (i=0; i<num_items; i++) {
                len += tdb_unpack(buf+len, buflen-len, "f", subkeyname);
                werr = regsubkey_ctr_addkey(ctr, subkeyname);