From 95108f1c60aaa0407aa4eb8c9a567e90302253c6 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 25 Nov 2009 21:34:55 +0100 Subject: s3-registry: fix REG_MULTI_SZ handling in registry_push_value. Catched by smbconftort test on the buildfarm. Guenther --- source3/lib/util_reg_api.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/source3/lib/util_reg_api.c b/source3/lib/util_reg_api.c index 309fa62762..7150444cf6 100644 --- a/source3/lib/util_reg_api.c +++ b/source3/lib/util_reg_api.c @@ -161,12 +161,29 @@ WERROR registry_push_value(TALLOC_CTX *mem_ctx, } break; } - case REG_MULTI_SZ: - if (!push_reg_multi_sz(mem_ctx, presult, (const char **)value->v.multi_sz.strings)) - { + case REG_MULTI_SZ: { + /* handle the case where we don't get a NULL terminated array */ + const char **array; + int i; + + array = talloc_array(mem_ctx, const char *, + value->v.multi_sz.num_strings + 1); + if (!array) { + return WERR_NOMEM; + } + + for (i=0; i < value->v.multi_sz.num_strings; i++) { + array[i] = value->v.multi_sz.strings[i]; + } + array[i] = NULL; + + if (!push_reg_multi_sz(mem_ctx, presult, array)) { + talloc_free(array); return WERR_NOMEM; } + talloc_free(array); break; + } case REG_BINARY: *presult = data_blob_talloc(mem_ctx, value->v.binary.data, -- cgit