From e596e2fb6ff7be833110b2095cefe597993b5308 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=BCnther=20Deschner?= Date: Fri, 25 Sep 2009 11:35:46 +0200 Subject: [PATCH] s3-util: use pull_reg_multi_sz in reg_pull_multi_sz. Guenther --- source3/lib/util_reg.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/source3/lib/util_reg.c b/source3/lib/util_reg.c index dbf608bc4a..ca46f86f69 100644 --- a/source3/lib/util_reg.c +++ b/source3/lib/util_reg.c @@ -76,39 +76,23 @@ const char *reg_type_lookup(enum winreg_Type type) WERROR reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len, uint32 *num_values, char ***values) { - const smb_ucs2_t *p = (const smb_ucs2_t *)buf; - *num_values = 0; + DATA_BLOB blob; + const char **vals; + int i; - /* - * Make sure that a talloc context for the strings retrieved exists - */ + blob = data_blob_const((uint8_t *)buf, len); - if (!(*values = TALLOC_ARRAY(mem_ctx, char *, 1))) { + if (!pull_reg_multi_sz(mem_ctx, &blob, &vals)) { return WERR_NOMEM; } - len /= 2; /* buf is a set of UCS2 strings */ - - while (len > 0) { - char *val; - size_t dstlen, thislen; - - thislen = strnlen_w(p, len) + 1; - if (!convert_string_allocate(*values, CH_UTF16LE, CH_UNIX, - p, thislen*2, (void *)&val, &dstlen, true)) { - TALLOC_FREE(*values); - return WERR_NOMEM; - } - - ADD_TO_ARRAY(*values, char *, val, values, num_values); - if (*values == NULL) { - return WERR_NOMEM; - } - - p += thislen; - len -= thislen; + for (i=0; vals[i]; i++) { + ;; } + *num_values = i; + *values = (char **)vals; + return WERR_OK; } -- 2.34.1