summaryrefslogtreecommitdiff
path: root/source3/registry
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2007-09-07 14:41:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:30:32 -0500
commitcc7bc29757c0ea6739e06b96775c7c2b9a57f8ce (patch)
tree116bf2cab3dda4c241cd7a29423f9a56255469fd /source3/registry
parent628e4d90090238e9109893401e7a92344199268b (diff)
downloadsamba-cc7bc29757c0ea6739e06b96775c7c2b9a57f8ce.tar.gz
samba-cc7bc29757c0ea6739e06b96775c7c2b9a57f8ce.tar.bz2
samba-cc7bc29757c0ea6739e06b96775c7c2b9a57f8ce.zip
r24998: Add a function regval_compose() to compose a REGISTRY_VALUE from
input data. Use this function in a first step to refactor the canonicalization code of smbconf_store_values(). Michael (This used to be commit f4caa2d7d412e2b9bb2a1ce71514551569ccf373)
Diffstat (limited to 'source3/registry')
-rw-r--r--source3/registry/reg_objects.c30
-rw-r--r--source3/registry/reg_smbconf.c16
2 files changed, 42 insertions, 4 deletions
diff --git a/source3/registry/reg_objects.c b/source3/registry/reg_objects.c
index f759a921d2..ba37b9014b 100644
--- a/source3/registry/reg_objects.c
+++ b/source3/registry/reg_objects.c
@@ -270,6 +270,36 @@ BOOL regval_ctr_key_exists( REGVAL_CTR *ctr, const char *value )
return False;
}
+
+/***********************************************************************
+ * compose a REGISTRY_VALUE from input data
+ **********************************************************************/
+
+REGISTRY_VALUE *regval_compose(TALLOC_CTX *ctx, const char *name, uint16 type,
+ const char *data_p, size_t size)
+{
+ REGISTRY_VALUE *regval = TALLOC_P(ctx, REGISTRY_VALUE);
+
+ if (regval == NULL) {
+ return NULL;
+ }
+
+ fstrcpy(regval->valuename, name);
+ regval->type = type;
+ if (size) {
+ regval->data_p = (uint8 *)TALLOC_MEMDUP(regval, data_p, size);
+ if (!regval->data_p) {
+ TALLOC_FREE(regval);
+ return NULL;
+ }
+ } else {
+ regval->data_p = NULL;
+ }
+ regval->size = size;
+
+ return regval;
+}
+
/***********************************************************************
Add a new registry value to the array
**********************************************************************/
diff --git a/source3/registry/reg_smbconf.c b/source3/registry/reg_smbconf.c
index e2c7e7ea08..f2a8b6ee8b 100644
--- a/source3/registry/reg_smbconf.c
+++ b/source3/registry/reg_smbconf.c
@@ -167,10 +167,18 @@ static BOOL smbconf_store_values( const char *key, REGVAL_CTR *val )
DEBUG(10, ("adding canonicalized parameter to "
"container.\n"));
- res = regval_ctr_addvalue(new_val_ctr, canon_valname,
- value->type,
- (char *)value_data.data,
- value_data.length);
+
+ theval = regval_compose(mem_ctx, canon_valname,
+ value->type,
+ (char *)value_data.data,
+ value_data.length);
+ if (theval == NULL) {
+ DEBUG(10, ("error composing registry value. "
+ "(no memory?)\n"));
+ TALLOC_FREE(mem_ctx);
+ return False;
+ }
+ res = regval_ctr_copyvalue(new_val_ctr, theval);
if (res == 0) {
DEBUG(10, ("error calling regval_ctr_addvalue. "
"(no memory?)\n"));