summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2008-09-15 15:13:25 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-10-21 14:40:41 +0200
commitb23c3c24c2ffa8c8fa73ae90947d7e0a01b796c0 (patch)
tree031fa2979234a4e1b7608f565c27cac5a4f84801
parent5f2ab665bd8d17ca7c204a9720e06895874ad2ef (diff)
downloadsamba-b23c3c24c2ffa8c8fa73ae90947d7e0a01b796c0.tar.gz
samba-b23c3c24c2ffa8c8fa73ae90947d7e0a01b796c0.tar.bz2
samba-b23c3c24c2ffa8c8fa73ae90947d7e0a01b796c0.zip
Registry server "reg_ldb_unpack_value": Let "data" pointer be NULL
Prevent segfaults in some client applications (e.g. regdiff)
-rw-r--r--source4/lib/registry/ldb.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c
index be844d75d5..d15fdb3457 100644
--- a/source4/lib/registry/ldb.c
+++ b/source4/lib/registry/ldb.c
@@ -54,35 +54,39 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx,
value_type = ldb_msg_find_attr_as_uint(msg, "type", 0);
if (type != NULL)
*type = value_type;
- val = ldb_msg_find_ldb_val(msg, "data");
- switch (value_type)
- {
- case REG_SZ:
- case REG_EXPAND_SZ:
- data->length = convert_string_talloc(mem_ctx, iconv_convenience, CH_UNIX, CH_UTF16,
+ if (data != NULL) {
+ val = ldb_msg_find_ldb_val(msg, "data");
+
+ switch (value_type)
+ {
+ case REG_SZ:
+ case REG_EXPAND_SZ:
+ data->length = convert_string_talloc(mem_ctx,
+ iconv_convenience, CH_UNIX, CH_UTF16,
val->data, val->length,
(void **)&data->data);
- break;
+ break;
- case REG_BINARY:
- if (val)
- *data = strhex_to_data_blob((char *)val->data);
- else {
- data->data = NULL;
- data->length = 0;
- }
- break;
+ case REG_BINARY:
+ if (val != NULL)
+ *data = strhex_to_data_blob((char *)val->data);
+ else {
+ data->data = NULL;
+ data->length = 0;
+ }
+ break;
- case REG_DWORD: {
- uint32_t tmp = strtoul((char *)val->data, NULL, 0);
- *data = data_blob_talloc(mem_ctx, &tmp, 4);
- }
- break;
+ case REG_DWORD: {
+ uint32_t tmp = strtoul((char *)val->data, NULL, 0);
+ *data = data_blob_talloc(mem_ctx, &tmp, 4);
+ }
+ break;
- default:
- *data = data_blob_talloc(mem_ctx, val->data, val->length);
- break;
+ default:
+ *data = data_blob_talloc(mem_ctx, val->data, val->length);
+ break;
+ }
}
}