s3-spoolss: fix enumprinter key client and server.
authorGünther Deschner <gd@samba.org>
Thu, 10 Dec 2009 13:20:22 +0000 (14:20 +0100)
committerKarolin Seeger <kseeger@samba.org>
Mon, 14 Dec 2009 09:52:50 +0000 (10:52 +0100)
Guenther
(cherry picked from commit f20effc437970d826c5bd4f047ff47e23e7a1a73)

source3/rpc_client/cli_spoolss.c
source3/rpc_server/srv_spoolss_nt.c

index d2e655666883c493c855f7ab6e25a8772f599819..bc4a4e78ed5cbdf229397c96f71d66eb1d5a34e3 100644 (file)
@@ -760,11 +760,13 @@ WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli,
        NTSTATUS status;
        WERROR werror;
        uint32_t needed;
-       struct spoolss_StringArray2 _key_buffer;
+       union spoolss_KeyNames _key_buffer;
+       uint32_t _ndr_size;
 
        status = rpccli_spoolss_EnumPrinterKey(cli, mem_ctx,
                                               handle,
                                               key_name,
+                                              &_ndr_size,
                                               &_key_buffer,
                                               offered,
                                               &needed,
@@ -775,13 +777,14 @@ WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli,
                status = rpccli_spoolss_EnumPrinterKey(cli, mem_ctx,
                                                       handle,
                                                       key_name,
+                                                      &_ndr_size,
                                                       &_key_buffer,
                                                       offered,
                                                       &needed,
                                                       &werror);
        }
 
-       *key_buffer = _key_buffer.string;
+       *key_buffer = _key_buffer.string_array;
 
        return werror;
 }
index ecad469d8200a0a33463585237406f52e520615b..e88c73304be9bebb262133474182aae8f099eec5 100644 (file)
@@ -9292,12 +9292,20 @@ WERROR _spoolss_EnumPrinterKey(pipes_struct *p,
                goto done;
        }
 
-       array = talloc_zero_array(r->out.key_buffer, const char *, num_keys + 1);
+       array = talloc_zero_array(r->out.key_buffer, const char *, num_keys + 2);
        if (!array) {
                result = WERR_NOMEM;
                goto done;
        }
 
+       if (!num_keys) {
+               array[0] = talloc_strdup(array, "");
+               if (!array[0]) {
+                       result = WERR_NOMEM;
+                       goto done;
+               }
+       }
+
        for (i=0; i < num_keys; i++) {
 
                DEBUG(10,("_spoolss_EnumPrinterKey: adding keyname: %s\n",
@@ -9315,13 +9323,14 @@ WERROR _spoolss_EnumPrinterKey(pipes_struct *p,
                goto done;
        }
 
+       *r->out._ndr_size = r->in.offered / 2;
        *r->out.needed = blob.length;
 
        if (r->in.offered < *r->out.needed) {
                result = WERR_MORE_DATA;
        } else {
                result = WERR_OK;
-               r->out.key_buffer->string = array;
+               r->out.key_buffer->string_array = array;
        }
 
  done: