s3: use push_reg_multi_sz().
authorGünther Deschner <gd@samba.org>
Thu, 24 Sep 2009 22:36:43 +0000 (00:36 +0200)
committerGünther Deschner <gd@samba.org>
Tue, 29 Sep 2009 22:30:25 +0000 (00:30 +0200)
Guenther

source3/registry/reg_eventlog.c
source3/rpc_server/srv_ntsvcs_nt.c

index 4d395eddb10539df059673ba4056f425f74247e0..dbeaa64bad83eb10092115ab6d98250fabbe3f74 100644 (file)
@@ -191,13 +191,12 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename,
           need to add KEY of source to KEY_EVENTLOG/<eventlog>/<source> */
 
        const char **elogs = lp_eventlog_list(  );
-       char **wrklist, **wp;
+       const char **wrklist, **wp;
        char *evtlogpath = NULL;
        struct regsubkey_ctr *subkeys;
        struct regval_ctr *values;
        struct regval_blob *rval;
-       uint16 *msz_wp;
-       int mbytes, ii;
+       int ii;
        bool already_in;
        int i;
        int numsources;
@@ -287,8 +286,9 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename,
        wp = wrklist;
 
        if ( !already_in ) {
+               DATA_BLOB blob;
                /* make a new list with an additional entry; copy values, add another */
-               wp = TALLOC_ARRAY(ctx, char *, numsources + 2 );
+               wp = TALLOC_ARRAY(ctx, const char *, numsources + 2 );
 
                if ( !wp ) {
                        DEBUG( 0, ( "talloc() failed \n" ) );
@@ -297,12 +297,14 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename,
                memcpy( wp, wrklist, sizeof( char * ) * numsources );
                *( wp + numsources ) = ( char * ) sourcename;
                *( wp + numsources + 1 ) = NULL;
-               mbytes = regval_build_multi_sz( wp, &msz_wp );
-               dump_data( 1, ( uint8 * ) msz_wp, mbytes );
+               if (!push_reg_multi_sz(ctx, &blob, wp)) {
+                       return false;
+               }
+               dump_data( 1, blob.data, blob.length);
                regval_ctr_addvalue( values, "Sources", REG_MULTI_SZ,
-                                    ( char * ) msz_wp, mbytes );
+                                    ( char * ) blob.data, blob.length);
                regdb_store_values( evtlogpath, values );
-               TALLOC_FREE(msz_wp);
+               data_blob_free(&blob);
        } else {
                DEBUG( 3,
                       ( "Source name [%s] found in existing list of sources\n",
index 553707bfe5f55db76b258436db079b94d381eec7..357478f274dba0a62f07b8364755f8279f5ef05f 100644 (file)
@@ -76,9 +76,8 @@ WERROR _PNP_GetDeviceList(pipes_struct *p,
 {
        char *devicepath;
        uint32_t size = 0;
-       char **multi_sz = NULL;
-       size_t multi_sz_len;
-       uint16_t *multi_sz_buf;
+       const char **multi_sz = NULL;
+       DATA_BLOB blob;
 
        if ((r->in.flags & CM_GETIDLIST_FILTER_SERVICE) &&
            (!r->in.filter)) {
@@ -95,23 +94,22 @@ WERROR _PNP_GetDeviceList(pipes_struct *p,
                return WERR_CM_BUFFER_SMALL;
        }
 
-       multi_sz = talloc_zero_array(p->mem_ctx, char *, 2);
+       multi_sz = talloc_zero_array(p->mem_ctx, const char *, 2);
        if (!multi_sz) {
                return WERR_NOMEM;
        }
 
        multi_sz[0] = devicepath;
 
-       multi_sz_len = regval_build_multi_sz(multi_sz, &multi_sz_buf);
-       if (!multi_sz_len) {
+       if (!push_reg_multi_sz(multi_sz, &blob, multi_sz)) {
                return WERR_NOMEM;
        }
 
-       if (*r->in.length < multi_sz_len/2) {
+       if (*r->in.length < blob.length/2) {
                return WERR_CM_BUFFER_SMALL;
        }
 
-       memcpy(r->out.buffer, multi_sz_buf, multi_sz_len);
+       memcpy(r->out.buffer, blob.data, blob.length);
 
        return WERR_OK;
 }