From: Günther Deschner Date: Wed, 25 Nov 2009 20:34:55 +0000 (+0100) Subject: s3-registry: fix REG_MULTI_SZ handling in registry_push_value. X-Git-Tag: samba-4.0.0alpha9~175 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=95108f1c60aaa0407aa4eb8c9a567e90302253c6;p=thirdparty%2Fsamba.git s3-registry: fix REG_MULTI_SZ handling in registry_push_value. Catched by smbconftort test on the buildfarm. Guenther --- diff --git a/source3/lib/util_reg_api.c b/source3/lib/util_reg_api.c index 309fa627622..7150444cf67 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,