s3-util: use pull_reg_multi_sz in reg_pull_multi_sz.
authorGünther Deschner <gd@samba.org>
Fri, 25 Sep 2009 09:35:46 +0000 (11:35 +0200)
committerGregor Beck <gbeck@sernet.de>
Wed, 29 Sep 2010 13:18:07 +0000 (15:18 +0200)
Guenther

source3/lib/util_reg.c

index dbf608bc4adaf9eb3a8e5921d9ea147df303a2b1..ca46f86f6980105639d4b4a60436089c782c3796 100644 (file)
@@ -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;
 }