s3-spoolss: simplify _spoolss_EnumPrinterKey a little more.
authorGünther Deschner <gd@samba.org>
Thu, 26 Nov 2009 18:01:54 +0000 (19:01 +0100)
committerKarolin Seeger <kseeger@samba.org>
Mon, 30 Nov 2009 15:09:49 +0000 (16:09 +0100)
Guenther
(cherry picked from commit e512ccb5b677fa7f285829ec645fc067837c0e11)

Part of a fix for bug #6883 (Add Printer fails with 0x000006f7 on Windows 7).

source3/rpc_server/srv_spoolss_nt.c

index bf02ee0a53c8c8b6ce902673bafce9e2416cea06..af0c952cf55936e1f75488d267b49d406f84e4d1 100644 (file)
@@ -9288,10 +9288,6 @@ WERROR _spoolss_EnumPrinterKey(pipes_struct *p,
                goto done;
        }
 
-       /* two byte termination (a multisz) */
-
-       *r->out.needed = 2;
-
        array = talloc_zero_array(r->out.key_buffer, const char *, num_keys + 1);
        if (!array) {
                result = WERR_NOMEM;
@@ -9308,23 +9304,19 @@ WERROR _spoolss_EnumPrinterKey(pipes_struct *p,
                        result = WERR_NOMEM;
                        goto done;
                }
-
-               *r->out.needed += strlen_m_term(keynames[i]) * 2;
-       }
-
-       if (r->in.offered < *r->out.needed) {
-               result = WERR_MORE_DATA;
-               goto done;
        }
 
-       result = WERR_OK;
-
        if (!push_reg_multi_sz(p->mem_ctx, &blob, array)) {
                result = WERR_NOMEM;
                goto done;
        }
 
-       if (r->in.offered >= blob.length) {
+       *r->out.needed = blob.length;
+
+       if (r->in.offered < *r->out.needed) {
+               result = WERR_MORE_DATA;
+       } else {
+               result = WERR_OK;
                memcpy(r->out.key_buffer, blob.data, blob.length);
        }