summaryrefslogtreecommitdiff
path: root/source3/libgpo
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2010-06-29 16:13:15 +0200
committerGünther Deschner <gd@samba.org>2010-07-02 10:50:21 +0200
commitb381fba0892021f164223bae8b0951014a28735e (patch)
tree5dc8f39ea4997a0863e9506dbe9387ca7ceb6971 /source3/libgpo
parent84c5dd1e4bb1b4c45d7b5ac68ab432cfc399835c (diff)
downloadsamba-b381fba0892021f164223bae8b0951014a28735e.tar.gz
samba-b381fba0892021f164223bae8b0951014a28735e.tar.bz2
samba-b381fba0892021f164223bae8b0951014a28735e.zip
s3-registry: avoid using registry_value union.
Just pull and push data as is. Guenther
Diffstat (limited to 'source3/libgpo')
-rw-r--r--source3/libgpo/gpext/registry.c21
-rw-r--r--source3/libgpo/gpext/scripts.c8
-rw-r--r--source3/libgpo/gpo_reg.c78
3 files changed, 63 insertions, 44 deletions
diff --git a/source3/libgpo/gpext/registry.c b/source3/libgpo/gpext/registry.c
index 57840a4c06..a7e8a5e948 100644
--- a/source3/libgpo/gpext/registry.c
+++ b/source3/libgpo/gpext/registry.c
@@ -293,24 +293,19 @@ static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx,
switch (data->type) {
case REG_DWORD:
- data->v.dword = atoi((char *)file_entry->data);
+ if (file_entry->size < 4) {
+ return false;
+ }
+ data->data = data_blob_talloc(mem_ctx, NULL, 4);
+ SIVAL(data->data.data, 0, atoi((char *)file_entry->data));
break;
case REG_BINARY:
- data->v.binary = data_blob_talloc(mem_ctx,
- file_entry->data,
- file_entry->size);
+ case REG_SZ:
+ data->data.length = file_entry->size;
+ data->data.data = file_entry->data;
break;
case REG_NONE:
break;
- case REG_SZ:
- if (!pull_ucs2_talloc(mem_ctx, &data->v.sz.str,
- (const smb_ucs2_t *)
- file_entry->data,
- &data->v.sz.len)) {
- data->v.sz.len = -1;
- }
-
- break;
case REG_DWORD_BIG_ENDIAN:
case REG_EXPAND_SZ:
case REG_LINK:
diff --git a/source3/libgpo/gpext/scripts.c b/source3/libgpo/gpext/scripts.c
index f03dff4e34..fee1461f01 100644
--- a/source3/libgpo/gpext/scripts.c
+++ b/source3/libgpo/gpext/scripts.c
@@ -96,11 +96,13 @@ static NTSTATUS generate_gp_registry_entry(TALLOC_CTX *mem_ctx,
data->type = data_type;
switch (data->type) {
case REG_QWORD:
- data->v.qword = *(uint64_t *)data_p;
+ data->data = data_blob_talloc(mem_ctx, NULL, 8);
+ SBVAL(data->data.data, 0, *(uint64_t *)data_p);
break;
case REG_SZ:
- data->v.sz.str = talloc_strdup(mem_ctx, (char *)data_p);
- data->v.sz.len = strlen(data->v.sz.str);
+ if (!push_reg_sz(mem_ctx, &data->data, (char *)data_p)) {
+ return NT_STATUS_NO_MEMORY;
+ }
break;
default:
return NT_STATUS_NOT_SUPPORTED;
diff --git a/source3/libgpo/gpo_reg.c b/source3/libgpo/gpo_reg.c
index c4970f6018..5b56ecd365 100644
--- a/source3/libgpo/gpo_reg.c
+++ b/source3/libgpo/gpo_reg.c
@@ -165,15 +165,11 @@ WERROR gp_store_reg_val_sz(TALLOC_CTX *mem_ctx,
const char *val)
{
struct registry_value reg_val;
- ZERO_STRUCT(reg_val);
-
- /* FIXME: hack */
- val = val ? val : " ";
reg_val.type = REG_SZ;
- reg_val.v.sz.len = strlen(val);
- reg_val.v.sz.str = talloc_strdup(mem_ctx, val);
- W_ERROR_HAVE_NO_MEMORY(reg_val.v.sz.str);
+ if (!push_reg_sz(mem_ctx, &reg_val.data, val)) {
+ return WERR_NOMEM;
+ }
return reg_setvalue(key, val_name, &reg_val);
}
@@ -187,10 +183,10 @@ static WERROR gp_store_reg_val_dword(TALLOC_CTX *mem_ctx,
uint32_t val)
{
struct registry_value reg_val;
- ZERO_STRUCT(reg_val);
reg_val.type = REG_DWORD;
- reg_val.v.dword = val;
+ reg_val.data = data_blob_talloc(mem_ctx, NULL, 4);
+ SIVAL(reg_val.data.data, 0, val);
return reg_setvalue(key, val_name, &reg_val);
}
@@ -213,8 +209,9 @@ WERROR gp_read_reg_val_sz(TALLOC_CTX *mem_ctx,
return WERR_INVALID_DATATYPE;
}
- *val = talloc_strdup(mem_ctx, reg_val->v.sz.str);
- W_ERROR_HAVE_NO_MEMORY(*val);
+ if (!pull_reg_sz(mem_ctx, &reg_val->data, val)) {
+ return WERR_NOMEM;
+ }
return WERR_OK;
}
@@ -237,7 +234,10 @@ static WERROR gp_read_reg_val_dword(TALLOC_CTX *mem_ctx,
return WERR_INVALID_DATATYPE;
}
- *val = reg_val->v.dword;
+ if (reg_val->data.length < 4) {
+ return WERR_INSUFFICIENT_BUFFER;
+ }
+ *val = IVAL(reg_val->data.data, 0);
return WERR_OK;
}
@@ -797,34 +797,56 @@ void dump_reg_val(int lvl, const char *direction,
direction, key, subkey, type_str));
switch (val->type) {
- case REG_DWORD:
+ case REG_DWORD: {
+ uint32_t v;
+ if (val->data.length < 4) {
+ break;
+ }
+ v = IVAL(val->data.data, 0);
DEBUG(lvl,("%d (0x%08x)\n",
- (int)val->v.dword, val->v.dword));
+ (int)v, v));
break;
- case REG_QWORD:
+ }
+ case REG_QWORD: {
+ uint64_t v;
+ if (val->data.length < 8) {
+ break;
+ }
+ v = BVAL(val->data.data, 0);
DEBUG(lvl,("%d (0x%016llx)\n",
- (int)val->v.qword,
- (unsigned long long)val->v.qword));
+ (int)v,
+ (unsigned long long)v));
break;
- case REG_SZ:
+ }
+ case REG_SZ: {
+ const char *s;
+ if (!pull_reg_sz(talloc_tos(), &val->data, &s)) {
+ break;
+ }
DEBUG(lvl,("%s (length: %d)\n",
- val->v.sz.str,
- (int)val->v.sz.len));
+ s, (int)strlen_m(s)));
break;
- case REG_MULTI_SZ:
- DEBUG(lvl,("(num_strings: %d)\n",
- val->v.multi_sz.num_strings));
- for (i=0; i < val->v.multi_sz.num_strings; i++) {
- DEBUGADD(lvl,("\t%s\n",
- val->v.multi_sz.strings[i]));
+ }
+ case REG_MULTI_SZ: {
+ const char **a;
+ if (!pull_reg_multi_sz(talloc_tos(), &val->data, &a)) {
+ break;
+ }
+ for (i=0; a[i] != NULL; i++) {
+ ;;
+ }
+ DEBUG(lvl,("(num_strings: %d)\n", i));
+ for (i=0; a[i] != NULL; i++) {
+ DEBUGADD(lvl,("\t%s\n", a[i]));
}
break;
+ }
case REG_NONE:
DEBUG(lvl,("\n"));
break;
case REG_BINARY:
- dump_data(lvl, val->v.binary.data,
- val->v.binary.length);
+ dump_data(lvl, val->data.data,
+ val->data.length);
break;
default:
DEBUG(lvl,("unsupported type: %d\n", val->type));