diff options
author | Wilco Baan Hofman <wilco@baanhofman.nl> | 2010-10-03 06:36:49 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2010-10-03 15:31:38 +0200 |
commit | e2eae17961ef7fd3457c126bc19b3ef54149be00 (patch) | |
tree | d4c6518a22cd939724295adbf75547579f49b372 /source4/lib/registry | |
parent | a8adadbe5b5118d6768953d35b21475b06474412 (diff) | |
download | samba-e2eae17961ef7fd3457c126bc19b3ef54149be00.tar.gz samba-e2eae17961ef7fd3457c126bc19b3ef54149be00.tar.bz2 samba-e2eae17961ef7fd3457c126bc19b3ef54149be00.zip |
Make sure REG_SZ is properly written to a .reg file (not as hex(1)), fix trailing comma REG_BINARY.
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Diffstat (limited to 'source4/lib/registry')
-rw-r--r-- | source4/lib/registry/patchfile_dotreg.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/source4/lib/registry/patchfile_dotreg.c b/source4/lib/registry/patchfile_dotreg.c index aadc2f062a..b08900f43a 100644 --- a/source4/lib/registry/patchfile_dotreg.c +++ b/source4/lib/registry/patchfile_dotreg.c @@ -57,7 +57,8 @@ _PUBLIC_ char *dotreg_data_blob_hex_string(TALLOC_CTX *mem_ctx, const DATA_BLOB for (i = 0; i < blob->length; i++) slprintf(&hex_string[i*3], 4, "%02X,", blob->data[i]); - hex_string[(blob->length*3)] = '\0'; + /* Remove last comma and NULL-terminate the string */ + hex_string[(blob->length*3)-1] = '\0'; return hex_string; } @@ -121,21 +122,34 @@ static WERROR reg_dotreg_diff_set_value(void *_data, const char *path, struct dotreg_data *data = (struct dotreg_data *)_data; char *data_string = reg_val_dotreg_string(NULL, value_type, value); - char *type_string; + char *data_incl_type; W_ERROR_HAVE_NO_MEMORY(data_string); - if (value_type == REG_DWORD) { - type_string = talloc_strdup(data_string ,"dword"); - } else if (value_type == REG_BINARY) { - type_string = talloc_strdup(data_string, "hex"); - } else { - type_string = talloc_asprintf(data_string, "hex(%x)", value_type); + + switch (value_type) { + case REG_SZ: + data_incl_type = talloc_asprintf(data_string, "\"%s\"", + data_string); + break; + case REG_DWORD: + data_incl_type = talloc_asprintf(data_string, + "dword:%s", data_string); + break; + case REG_BINARY: + data_incl_type = talloc_asprintf(data_string, "hex:%s", + data_string); + break; + default: + data_incl_type = talloc_asprintf(data_string, "hex(%x):%s", + value_type, data_string); + break; } + if (value_name[0] == '\0') { - fdprintf(data->fd, "@=%s:%s\n", type_string, data_string); + fdprintf(data->fd, "@=%s\n", data_incl_type); } else { - fdprintf(data->fd, "\"%s\"=%s:%s\n", - value_name, type_string, data_string); + fdprintf(data->fd, "\"%s\"=%s\n", + value_name, data_incl_type); } talloc_free(data_string); |