r4213: Store REG_SZ in UTF16, not the unix charset..
authorJelmer Vernooij <jelmer@samba.org>
Wed, 15 Dec 2004 02:27:22 +0000 (02:27 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:07:27 +0000 (13:07 -0500)
It is now possible to use the "Add..." button in the Security
tab of the File Properties Dialog box.
(This used to be commit 9fa25260d3f18dd0dd041477c48571b53d86f3c4)

source4/lib/registry/common/reg_util.c
source4/lib/registry/reg_backend_nt4.c
source4/registry.ldif
source4/rpc_server/winreg/rpc_winreg.c

index 68144fc56fdd10968553ea25564565ca983782a1..3da875ca0b62f9f6823974be1aefe0a1cb3a22a9 100644 (file)
@@ -57,11 +57,10 @@ char *reg_val_data_string(TALLOC_CTX *mem_ctx, struct registry_value *v)
   if(v->data_len == 0) return talloc_strdup(mem_ctx, "");
 
   switch (v->data_type) {
-  case REG_SZ:
-         return talloc_strndup(mem_ctx, v->data_blk, v->data_len);
-
   case REG_EXPAND_SZ:
-         return talloc_strndup(mem_ctx, v->data_blk, v->data_len);
+  case REG_SZ:
+      convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, v->data_blk, v->data_len, (void **)&ret);
+         return ret;
 
   case REG_BINARY:
          ret = talloc(mem_ctx, v->data_len * 3 + 2);
@@ -120,8 +119,7 @@ BOOL reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const char *da
        {
                case REG_SZ:
                case REG_EXPAND_SZ:
-                       (*value)->data_blk = talloc_strdup(mem_ctx, data_str);
-                       (*value)->data_len = strlen(data_str);
+               (*value)->data_len = convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16, data_str, strlen(data_str), &(*value)->data_blk);
                        break;
                case REG_DWORD:
                        (*value)->data_len = sizeof(uint32);
index 5633156b2073aa038dc028d51153fce4832f46f9..6c48b9bd1b50581bfb30f49bc83f1a6231be2760 100644 (file)
@@ -935,13 +935,6 @@ static WERROR vk_to_val(TALLOC_CTX *mem_ctx, struct registry_key *parent, VK_HDR
                }
 
 
-               if(tmp->data_type == REG_SZ) {
-                       char *ret;
-               dat_len = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, dtmp, dat_len, (void **)&ret);
-                       dtmp = ret;
-               }
-
-
                tmp->data_blk = dtmp;
                tmp->data_len = dat_len;
        }
index 76339452d9186976e8dafe745deefede42fa54af..6775d19e07a80e28f2131f46da88d9cd37caea00 100644 (file)
@@ -1,43 +1,29 @@
-# editing 10 records
-# record 1
 dn: key=control,key=currentcontrolset,key=system,hive=
 key: control
 
-# record 2
 dn: key=services,key=control,key=currentcontrolset,key=system,hive=
 key: services
 
-# record 3
 dn: value=ProductType,key=productoptions,key=control,key=currentcontrolset,key=system,hive=
 value: ProductType
-data: WinNT
+data:: VwBpAG4ATgBUAA=
 type: 1
 
-# record 4
 dn: key=productoptions,key=control,key=currentcontrolset,key=system,hive=
 key: productoptions
 
-# record 5
 dn: key=system,hive=
 key: system
 
-# record 6
-dn: @BASEINFO
-sequenceNumber: 13
-
-# record 7
 dn: key=netlogon,key=services,key=currentcontrolset,key=system,hive=
 key: netlogon
 
-# record 8
 dn: key=services,key=currentcontrolset,key=system,hive=
 key: services
 
-# record 9
 dn: key=print,key=control,key=currentcontrolset,key=system,hive=
 key: print
 
-# record 10
 dn: key=currentcontrolset,key=system,hive=
 key: currentcontrolset
 
index 20bf7f9117fa3e10ed2c45522cd809aa25fc5e98..56e5c427cc675a9512d621cc8209d4be6d306019 100644 (file)
@@ -360,10 +360,16 @@ static WERROR winreg_QueryValue(struct dcesrv_call_state *dce_call, TALLOC_CTX *
                return result;
        }
 
+       /* Just asking for the size of the buffer */
        r->out.type = &val->data_type;
-       r->out.size = r->in.size;
        r->out.length = &val->data_len;
-       r->out.data = val->data_blk;
+       if (!r->in.data) {
+               r->out.size = talloc_p(mem_ctx, uint32);
+               *r->out.size = val->data_len;
+       } else {
+               r->out.size = r->in.size;
+               r->out.data = val->data_blk;
+       }
 
        return WERR_OK;
 }