From 79fccc45bc3acac5d9b15a3585e2526a3b1876f2 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Wed, 7 Apr 2010 20:14:46 +0200 Subject: s4:registry - "regf backend" - fix it up regarding REG_DWORD/REG_DWORD_BIG_ENDIAN_VALUES This is needed to make it platform independently work (also on big endian platforms as little endian). Also add a size check before storing a DWORD. --- source4/lib/registry/regf.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source4/lib/registry/regf.c') diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c index 5825ac18a8..615389e0e8 100644 --- a/source4/lib/registry/regf.c +++ b/source4/lib/registry/regf.c @@ -550,10 +550,11 @@ static WERROR regf_get_value(TALLOC_CTX *ctx, struct hive_key *key, *data_type = vk->data_type; if (vk->data_length & 0x80000000) { - vk->data_length &=~0x80000000; - data->data = (uint8_t *)talloc_memdup(ctx, (uint8_t *)&vk->data_offset, vk->data_length); + /* this is data of type "REG_DWORD" or "REG_DWORD_BIG_ENDIAN" */ + data->data = talloc_size(ctx, sizeof(uint32_t)); W_ERROR_HAVE_NO_MEMORY(data->data); - data->length = vk->data_length; + SIVAL(data->data, 0, vk->data_offset); + data->length = sizeof(uint32_t); } else { *data = hbin_get(regf, vk->data_offset); } @@ -1821,7 +1822,8 @@ static WERROR regf_set_value(struct hive_key *key, const char *name, /* Set the type and data */ vk.data_length = data.length; vk.data_type = type; - if (type == REG_DWORD) { + if ((data.length == sizeof(uint32_t)) && + ((type == REG_DWORD) || (type == REG_DWORD_BIG_ENDIAN))) { vk.data_length |= 0x80000000; vk.data_offset = IVAL(data.data, 0); } else { -- cgit