summaryrefslogtreecommitdiff
path: root/source4/torture/rpc
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-02-09 16:51:46 +0100
committerJelmer Vernooij <jelmer@samba.org>2009-02-09 16:51:46 +0100
commit9b366d703210b493aa1389bbdd288a2b00958766 (patch)
tree12acaf89af2c6bd2610018d267e2d8030d9b4bd6 /source4/torture/rpc
parent6d139ca4680abcbda5110f2f0886aa038ff62088 (diff)
parent1dadf17be847e3f93b72988bcc7e8620a8d5908c (diff)
downloadsamba-9b366d703210b493aa1389bbdd288a2b00958766.tar.gz
samba-9b366d703210b493aa1389bbdd288a2b00958766.tar.bz2
samba-9b366d703210b493aa1389bbdd288a2b00958766.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Diffstat (limited to 'source4/torture/rpc')
-rw-r--r--source4/torture/rpc/samba3rpc.c12
-rw-r--r--source4/torture/rpc/spoolss.c118
-rw-r--r--source4/torture/rpc/spoolss_win.c47
3 files changed, 129 insertions, 48 deletions
diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c
index 5b493db813..5f803b07d3 100644
--- a/source4/torture/rpc/samba3rpc.c
+++ b/source4/torture/rpc/samba3rpc.c
@@ -2617,12 +2617,14 @@ static bool enumprinters(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *pipe,
struct spoolss_EnumPrinters r;
NTSTATUS status;
DATA_BLOB blob;
+ uint32_t needed;
r.in.flags = PRINTER_ENUM_LOCAL;
r.in.server = talloc_asprintf(mem_ctx, "\\\\%s", servername);
r.in.level = level;
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
status = dcerpc_spoolss_EnumPrinters(pipe, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
@@ -2638,14 +2640,14 @@ static bool enumprinters(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *pipe,
return false;
}
- blob = data_blob_talloc_zero(mem_ctx, r.out.needed);
+ blob = data_blob_talloc_zero(mem_ctx, needed);
if (blob.data == NULL) {
d_printf("(%s) data_blob_talloc failed\n", __location__);
return false;
}
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_EnumPrinters(pipe, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
@@ -2668,6 +2670,7 @@ static NTSTATUS getprinterinfo(TALLOC_CTX *ctx, struct dcerpc_pipe *pipe,
struct spoolss_GetPrinter r;
DATA_BLOB blob;
NTSTATUS status;
+ uint32_t needed;
mem_ctx = talloc_new(ctx);
if (mem_ctx == NULL) {
@@ -2678,6 +2681,7 @@ static NTSTATUS getprinterinfo(TALLOC_CTX *ctx, struct dcerpc_pipe *pipe,
r.in.level = level;
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
status = dcerpc_spoolss_GetPrinter(pipe, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
@@ -2697,14 +2701,14 @@ static NTSTATUS getprinterinfo(TALLOC_CTX *ctx, struct dcerpc_pipe *pipe,
r.in.handle = handle;
r.in.level = level;
- blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
+ blob = data_blob_talloc(mem_ctx, NULL, needed);
if (blob.data == NULL) {
talloc_free(mem_ctx);
return NT_STATUS_NO_MEMORY;
}
memset(blob.data, 0, blob.length);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_GetPrinter(pipe, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 4a6ff480c4..7da3209eb3 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -106,11 +106,13 @@ static bool test_EnumPorts(struct torture_context *tctx,
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
DATA_BLOB blob;
+ uint32_t needed;
r.in.servername = "";
r.in.level = level;
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing EnumPorts level %u\n", r.in.level);
@@ -123,10 +125,10 @@ static bool test_EnumPorts(struct torture_context *tctx,
torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER,
"EnumPorts unexpected return code");
- blob = data_blob_talloc(ctx, NULL, r.out.needed);
+ blob = data_blob_talloc(ctx, NULL, needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_EnumPorts(p, ctx, &r);
torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPorts failed");
@@ -191,6 +193,7 @@ static bool test_GetPrinterDriverDirectory(struct torture_context *tctx,
}
};
int i;
+ uint32_t needed;
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i].level;
@@ -201,6 +204,7 @@ static bool test_GetPrinterDriverDirectory(struct torture_context *tctx,
r.in.level = level;
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing GetPrinterDriverDirectory level %u\n", r.in.level);
@@ -210,10 +214,10 @@ static bool test_GetPrinterDriverDirectory(struct torture_context *tctx,
torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER,
"GetPrinterDriverDirectory unexpected return code");
- blob = data_blob_talloc(ctx, NULL, r.out.needed);
+ blob = data_blob_talloc(ctx, NULL, needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_GetPrinterDriverDirectory(p, ctx, &r);
torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_GetPrinterDriverDirectory failed");
@@ -236,12 +240,14 @@ static bool test_EnumPrinterDrivers(struct torture_context *tctx,
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
DATA_BLOB blob;
+ uint32_t needed;
r.in.server = "";
r.in.environment = SPOOLSS_ARCHITECTURE_NT_X86;
r.in.level = level;
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing EnumPrinterDrivers level %u\n", r.in.level);
@@ -255,10 +261,10 @@ static bool test_EnumPrinterDrivers(struct torture_context *tctx,
torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER,
"EnumPrinterDrivers failed");
- blob = data_blob_talloc(ctx, NULL, r.out.needed);
+ blob = data_blob_talloc(ctx, NULL, needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_EnumPrinterDrivers(p, ctx, &r);
torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrinterDrivers failed");
@@ -351,11 +357,13 @@ static bool test_EnumMonitors(struct torture_context *tctx,
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
DATA_BLOB blob;
+ uint32_t needed;
r.in.servername = "";
r.in.level = level;
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing EnumMonitors level %u\n", r.in.level);
@@ -368,10 +376,10 @@ static bool test_EnumMonitors(struct torture_context *tctx,
torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER,
"EnumMonitors failed");
- blob = data_blob_talloc(ctx, NULL, r.out.needed);
+ blob = data_blob_talloc(ctx, NULL, needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_EnumMonitors(p, ctx, &r);
torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumMonitors failed");
@@ -420,12 +428,14 @@ static bool test_EnumPrintProcessors(struct torture_context *tctx,
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
DATA_BLOB blob;
+ uint32_t needed;
r.in.servername = "";
r.in.environment = "Windows NT x86";
r.in.level = level;
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing EnumPrintProcessors level %u\n", r.in.level);
@@ -438,10 +448,10 @@ static bool test_EnumPrintProcessors(struct torture_context *tctx,
torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER,
"EnumPrintProcessors unexpected return code");
- blob = data_blob_talloc(ctx, NULL, r.out.needed);
+ blob = data_blob_talloc(ctx, NULL, needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_EnumPrintProcessors(p, ctx, &r);
torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrintProcessors failed");
@@ -489,12 +499,14 @@ static bool test_EnumPrinters(struct torture_context *tctx,
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
DATA_BLOB blob;
+ uint32_t needed;
r.in.flags = PRINTER_ENUM_LOCAL;
r.in.server = "";
r.in.level = level;
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing EnumPrinters level %u\n", r.in.level);
@@ -507,10 +519,10 @@ static bool test_EnumPrinters(struct torture_context *tctx,
torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER,
"EnumPrinters unexpected return code");
- blob = data_blob_talloc(ctx, NULL, r.out.needed);
+ blob = data_blob_talloc(ctx, NULL, needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_EnumPrinters(p, ctx, &r);
torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrinters failed");
@@ -605,12 +617,14 @@ static bool test_GetPrinter(struct torture_context *tctx,
struct spoolss_GetPrinter r;
uint16_t levels[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
int i;
+ uint32_t needed;
for (i=0;i<ARRAY_SIZE(levels);i++) {
r.in.handle = handle;
r.in.level = levels[i];
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing GetPrinter level %u\n", r.in.level);
@@ -618,10 +632,10 @@ static bool test_GetPrinter(struct torture_context *tctx,
torture_assert_ntstatus_ok(tctx, status, "GetPrinter failed");
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_GetPrinter(p, tctx, &r);
}
@@ -659,12 +673,14 @@ static bool test_GetForm(struct torture_context *tctx,
{
NTSTATUS status;
struct spoolss_GetForm r;
+ uint32_t needed;
r.in.handle = handle;
r.in.form_name = form_name;
r.in.level = 1;
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing GetForm\n");
@@ -672,10 +688,10 @@ static bool test_GetForm(struct torture_context *tctx,
torture_assert_ntstatus_ok(tctx, status, "GetForm failed");
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_GetForm(p, tctx, &r);
torture_assert_ntstatus_ok(tctx, status, "GetForm failed");
@@ -696,11 +712,13 @@ static bool test_EnumForms(struct torture_context *tctx,
NTSTATUS status;
struct spoolss_EnumForms r;
bool ret = true;
+ uint32_t needed;
r.in.handle = handle;
r.in.level = 1;
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing EnumForms\n");
@@ -713,10 +731,10 @@ static bool test_EnumForms(struct torture_context *tctx,
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
union spoolss_FormInfo *info;
int j;
- DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_EnumForms(p, tctx, &r);
@@ -823,12 +841,14 @@ static bool test_EnumPorts_old(struct torture_context *tctx,
{
NTSTATUS status;
struct spoolss_EnumPorts r;
+ uint32_t needed;
r.in.servername = talloc_asprintf(tctx, "\\\\%s",
dcerpc_server_name(p));
r.in.level = 2;
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing EnumPorts\n");
@@ -837,10 +857,10 @@ static bool test_EnumPorts_old(struct torture_context *tctx,
torture_assert_ntstatus_ok(tctx, status, "EnumPorts failed");
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_EnumPorts(p, tctx, &r);
torture_assert_ntstatus_ok(tctx, status, "EnumPorts failed");
@@ -888,12 +908,14 @@ static bool test_GetJob(struct torture_context *tctx,
{
NTSTATUS status;
struct spoolss_GetJob r;
+ uint32_t needed;
r.in.handle = handle;
r.in.job_id = job_id;
r.in.level = 1;
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing GetJob\n");
@@ -901,10 +923,10 @@ static bool test_GetJob(struct torture_context *tctx,
torture_assert_ntstatus_ok(tctx, status, "GetJob failed");
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_GetJob(p, tctx, &r);
@@ -942,6 +964,7 @@ static bool test_EnumJobs(struct torture_context *tctx,
{
NTSTATUS status;
struct spoolss_EnumJobs r;
+ uint32_t needed;
r.in.handle = handle;
r.in.firstjob = 0;
@@ -949,6 +972,7 @@ static bool test_EnumJobs(struct torture_context *tctx,
r.in.level = 1;
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing EnumJobs\n");
@@ -959,10 +983,10 @@ static bool test_EnumJobs(struct torture_context *tctx,
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
union spoolss_JobInfo *info;
int j;
- DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_EnumJobs(p, tctx, &r);
@@ -997,12 +1021,14 @@ static bool test_DoPrintTest(struct torture_context *tctx,
struct spoolss_EndDocPrinter e;
int i;
uint32_t job_id;
+ uint32_t num_written;
torture_comment(tctx, "Testing StartDocPrinter\n");
s.in.handle = handle;
s.in.level = 1;
s.in.info.info1 = &info1;
+ s.out.job_id = &job_id;
info1.document_name = "TorturePrintJob";
info1.output_file = NULL;
info1.datatype = "RAW";
@@ -1011,8 +1037,6 @@ static bool test_DoPrintTest(struct torture_context *tctx,
torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_StartDocPrinter failed");
torture_assert_werr_ok(tctx, s.out.result, "StartDocPrinter failed");
- job_id = s.out.job_id;
-
for (i=1; i < 4; i++) {
torture_comment(tctx, "Testing StartPagePrinter: Page[%d]\n", i);
@@ -1027,6 +1051,7 @@ static bool test_DoPrintTest(struct torture_context *tctx,
w.in.handle = handle;
w.in.data = data_blob_string_const(talloc_asprintf(tctx,"TortureTestPage: %d\nData\n",i));
+ w.out.num_written = &num_written;
status = dcerpc_spoolss_WritePrinter(p, tctx, &w);
torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_WritePrinter failed");
@@ -1113,10 +1138,14 @@ static bool test_GetPrinterData(struct torture_context *tctx,
{
NTSTATUS status;
struct spoolss_GetPrinterData r;
+ uint32_t needed;
+ enum spoolss_PrinterDataType type;
r.in.handle = handle;
r.in.value_name = value_name;
r.in.offered = 0;
+ r.out.needed = &needed;
+ r.out.type = &type;
torture_comment(tctx, "Testing GetPrinterData\n");
@@ -1124,7 +1153,7 @@ static bool test_GetPrinterData(struct torture_context *tctx,
torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed");
if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_GetPrinterData(p, tctx, &r);
torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed");
@@ -1143,11 +1172,15 @@ static bool test_GetPrinterDataEx(struct torture_context *tctx,
{
NTSTATUS status;
struct spoolss_GetPrinterDataEx r;
+ uint32_t type;
+ uint32_t needed;
r.in.handle = handle;
r.in.key_name = key_name;
r.in.value_name = value_name;
r.in.offered = 0;
+ r.out.type = &type;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing GetPrinterDataEx\n");
@@ -1161,7 +1194,8 @@ static bool test_GetPrinterDataEx(struct torture_context *tctx,
}
if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
+ r.out.buffer = talloc_array(tctx, uint8_t, needed);
status = dcerpc_spoolss_GetPrinterDataEx(p, tctx, &r);
torture_assert_ntstatus_ok(tctx, status, "GetPrinterDataEx failed");
@@ -1228,17 +1262,22 @@ static bool test_EnumPrinterDataEx(struct torture_context *tctx,
{
NTSTATUS status;
struct spoolss_EnumPrinterDataEx r;
+ uint32_t needed;
+ uint32_t count;
r.in.handle = handle;
r.in.key_name = "PrinterDriverData";
r.in.offered = 0;
+ r.out.needed = &needed;
+ r.out.count = &count;
torture_comment(tctx, "Testing EnumPrinterDataEx\n");
status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &r);
torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDataEx failed");
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
+ r.out.buffer = talloc_array(tctx, uint8_t, needed);
status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &r);
@@ -1539,12 +1578,14 @@ static bool test_EnumPrinters_old(struct torture_context *tctx, struct dcerpc_pi
for (i=0;i<ARRAY_SIZE(levels);i++) {
union spoolss_PrinterInfo *info;
int j;
+ uint32_t needed;
r.in.flags = PRINTER_ENUM_LOCAL;
r.in.server = "";
r.in.level = levels[i];
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing EnumPrinters level %u\n", r.in.level);
@@ -1552,10 +1593,10 @@ static bool test_EnumPrinters_old(struct torture_context *tctx, struct dcerpc_pi
torture_assert_ntstatus_ok(tctx, status, "EnumPrinters failed");
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_EnumPrinters(p, tctx, &r);
}
@@ -1596,6 +1637,9 @@ static bool test_GetPrinterDriver2(struct dcerpc_pipe *p,
{
NTSTATUS status;
struct spoolss_GetPrinterDriver2 r;
+ uint32_t needed;
+ uint32_t server_major_version;
+ uint32_t server_minor_version;
r.in.handle = handle;
r.in.architecture = "W32X86";
@@ -1604,6 +1648,9 @@ static bool test_GetPrinterDriver2(struct dcerpc_pipe *p,
r.in.offered = 0;
r.in.client_major_version = 0;
r.in.client_minor_version = 0;
+ r.out.needed = &needed;
+ r.out.server_major_version = &server_major_version;
+ r.out.server_minor_version = &server_minor_version;
printf("Testing GetPrinterDriver2\n");
@@ -1614,7 +1661,7 @@ static bool test_GetPrinterDriver2(struct dcerpc_pipe *p,
}
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_GetPrinterDriver2(p, tctx, &r);
}
@@ -1644,11 +1691,14 @@ static bool test_EnumPrinterDrivers_old(struct torture_context *tctx,
for (i=0;i<ARRAY_SIZE(levels);i++) {
+ uint32_t needed;
+
r.in.server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.environment = "Windows NT x86";
r.in.level = levels[i];
r.in.buffer = NULL;
r.in.offered = 0;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing EnumPrinterDrivers level %u\n", r.in.level);
@@ -1657,10 +1707,10 @@ static bool test_EnumPrinterDrivers_old(struct torture_context *tctx,
torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDrivers failed");
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed);
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
- r.in.offered = r.out.needed;
+ r.in.offered = needed;
status = dcerpc_spoolss_EnumPrinterDrivers(p, tctx, &r);
}
diff --git a/source4/torture/rpc/spoolss_win.c b/source4/torture/rpc/spoolss_win.c
index ca61d1dddb..df0ab65f3a 100644
--- a/source4/torture/rpc/spoolss_win.c
+++ b/source4/torture/rpc/spoolss_win.c
@@ -155,11 +155,15 @@ static bool test_GetPrinterData(struct torture_context *tctx,
{
NTSTATUS status;
struct spoolss_GetPrinterData gpd;
+ uint32_t needed;
+ enum spoolss_PrinterDataType type;
torture_comment(tctx, "Testing GetPrinterData(%s).\n", value_name);
gpd.in.handle = handle;
gpd.in.value_name = value_name;
gpd.in.offered = 4;
+ gpd.out.needed = &needed;
+ gpd.out.type = &type;
status = dcerpc_spoolss_GetPrinterData(p, tctx, &gpd);
torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed.");
@@ -182,20 +186,22 @@ static bool test_EnumPrinters(struct torture_context *tctx,
NTSTATUS status;
struct spoolss_EnumPrinters ep;
DATA_BLOB blob = data_blob_talloc_zero(ctx, initial_blob_size);
+ uint32_t needed;
ep.in.flags = PRINTER_ENUM_NAME;
ep.in.server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
ep.in.level = 2;
ep.in.buffer = &blob;
ep.in.offered = initial_blob_size;
+ ep.out.needed = &needed;
status = dcerpc_spoolss_EnumPrinters(p, ctx, &ep);
torture_assert_ntstatus_ok(tctx, status, "EnumPrinters failed.");
if (W_ERROR_EQUAL(ep.out.result, WERR_INSUFFICIENT_BUFFER)) {
- blob = data_blob_talloc_zero(ctx, ep.out.needed);
+ blob = data_blob_talloc_zero(ctx, needed);
ep.in.buffer = &blob;
- ep.in.offered = ep.out.needed;
+ ep.in.offered = needed;
status = dcerpc_spoolss_EnumPrinters(p, ctx, &ep);
torture_assert_ntstatus_ok(tctx, status,"EnumPrinters failed.");
}
@@ -220,6 +226,7 @@ static bool test_GetPrinter(struct torture_context *tctx,
NTSTATUS status;
struct spoolss_GetPrinter gp;
DATA_BLOB blob = data_blob_talloc_zero(ctx, initial_blob_size);
+ uint32_t needed;
torture_comment(tctx, "Test GetPrinter level %d\n", level);
@@ -227,14 +234,15 @@ static bool test_GetPrinter(struct torture_context *tctx,
gp.in.level = level;
gp.in.buffer = (initial_blob_size == 0)?NULL:&blob;
gp.in.offered = initial_blob_size;
+ gp.out.needed = &needed;
status = dcerpc_spoolss_GetPrinter(p, tctx, &gp);
torture_assert_ntstatus_ok(tctx, status, "GetPrinter failed");
if (W_ERROR_EQUAL(gp.out.result, WERR_INSUFFICIENT_BUFFER)) {
- blob = data_blob_talloc_zero(ctx, gp.out.needed);
+ blob = data_blob_talloc_zero(ctx, needed);
gp.in.buffer = &blob;
- gp.in.offered = gp.out.needed;
+ gp.in.offered = needed;
status = dcerpc_spoolss_GetPrinter(p, tctx, &gp);
torture_assert_ntstatus_ok(tctx, status, "GetPrinter failed");
}
@@ -252,6 +260,7 @@ static bool test_EnumJobs(struct torture_context *tctx,
NTSTATUS status;
struct spoolss_EnumJobs ej;
DATA_BLOB blob = data_blob_talloc_zero(tctx, 1024);
+ uint32_t needed;
torture_comment(tctx, "Test EnumJobs\n");
@@ -259,6 +268,7 @@ static bool test_EnumJobs(struct torture_context *tctx,
ej.in.level = 2;
ej.in.buffer = &blob;
ej.in.offered = 1024;
+ ej.out.needed = &needed;
status = dcerpc_spoolss_EnumJobs(p, tctx, &ej);
torture_assert_ntstatus_ok(tctx, status, "EnumJobs failed");
@@ -274,6 +284,9 @@ static bool test_GetPrinterDriver2(struct torture_context *tctx,
NTSTATUS status;
struct spoolss_GetPrinterDriver2 gpd2;
DATA_BLOB blob = data_blob_talloc_zero(tctx, 87424);
+ uint32_t needed;
+ uint32_t server_major_version;
+ uint32_t server_minor_version;
torture_comment(tctx, "Testing GetPrinterDriver2\n");
@@ -284,6 +297,9 @@ static bool test_GetPrinterDriver2(struct torture_context *tctx,
gpd2.in.offered = 87424;
gpd2.in.client_major_version = 3;
gpd2.in.client_minor_version = 0;
+ gpd2.out.needed = &needed;
+ gpd2.out.server_major_version = &server_major_version;
+ gpd2.out.server_minor_version = &server_minor_version;
status = dcerpc_spoolss_GetPrinterDriver2(p, tctx, &gpd2);
torture_assert_ntstatus_ok(tctx, status, "GetPrinterDriver2 failed");
@@ -301,6 +317,7 @@ static bool test_EnumForms(struct torture_context *tctx,
NTSTATUS status;
struct spoolss_EnumForms ef;
DATA_BLOB blob = data_blob_talloc_zero(tctx, initial_blob_size);
+ uint32_t needed;
torture_comment(tctx, "Testing EnumForms\n");
@@ -308,14 +325,15 @@ static bool test_EnumForms(struct torture_context *tctx,
ef.in.level = 1;
ef.in.buffer = (initial_blob_size == 0)?NULL:&blob;
ef.in.offered = initial_blob_size;
+ ef.out.needed = &needed;
status = dcerpc_spoolss_EnumForms(p, tctx, &ef);
torture_assert_ntstatus_ok(tctx, status, "EnumForms failed");
if (W_ERROR_EQUAL(ef.out.result, WERR_INSUFFICIENT_BUFFER)) {
- blob = data_blob_talloc_zero(tctx, ef.out.needed);
+ blob = data_blob_talloc_zero(tctx, needed);
ef.in.buffer = &blob;
- ef.in.offered = ef.out.needed;
+ ef.in.offered = needed;
status = dcerpc_spoolss_EnumForms(p, tctx, &ef);
torture_assert_ntstatus_ok(tctx, status, "EnumForms failed");
}
@@ -339,14 +357,17 @@ static bool test_EnumPrinterKey(struct torture_context *tctx,
epk.in.handle = handle;
epk.in.key_name = talloc_strdup(tctx, key);
- epk.in.needed = needed;
+ epk.in.key_buffer_size = 0;
+ epk.out.needed = &needed;
+ epk.out.key_buffer = talloc_array(tctx, uint16_t, 0);
status = dcerpc_spoolss_EnumPrinterKey(p, tctx, &epk);
torture_assert_ntstatus_ok(tctx, status, "EnumPrinterKey failed");
if (W_ERROR_EQUAL(epk.out.result, WERR_MORE_DATA)) {
- epk.in.needed = epk.out.needed;
+ epk.in.key_buffer_size = needed;
+ epk.out.key_buffer = talloc_array(tctx, uint16_t, needed/2);
status = dcerpc_spoolss_EnumPrinterKey(p, tctx, &epk);
torture_assert_ntstatus_ok(tctx, status,
"EnumPrinterKey failed");
@@ -355,7 +376,7 @@ static bool test_EnumPrinterKey(struct torture_context *tctx,
torture_assert_werr_ok(tctx, epk.out.result, "EnumPrinterKey failed");
convert_string_talloc_convenience(ctx, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16,
- CH_UNIX, epk.out.key_buffer, epk.out.needed,
+ CH_UNIX, epk.out.key_buffer, *epk.out.needed,
(void**)&ctx->printer_keys);
return true;
@@ -370,17 +391,23 @@ static bool test_EnumPrinterDataEx(struct torture_context *tctx,
{
NTSTATUS status;
struct spoolss_EnumPrinterDataEx epde;
+ uint32_t needed;
+ uint32_t count;
torture_comment(tctx, "Testing EnumPrinterDataEx(%s)\n", key);
epde.in.handle = handle;
epde.in.key_name = talloc_strdup(tctx, key);
epde.in.offered = 0;
+ epde.out.needed = &needed;
+ epde.out.count = &count;
+ epde.out.buffer = talloc_array(tctx, uint8_t, 0);
status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &epde);
torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDataEx failed.");
if (W_ERROR_EQUAL(epde.out.result, WERR_MORE_DATA)) {
- epde.in.offered = epde.out.needed;
+ epde.in.offered = needed;
+ epde.out.buffer = talloc_array(tctx, uint8_t, needed);
status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &epde);
torture_assert_ntstatus_ok(tctx, status,
"EnumPrinterDataEx failed.");