summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-02-06 17:09:30 +0100
committerGünther Deschner <gd@samba.org>2009-02-06 17:36:10 +0100
commitafe300cb527c19cffa8667db4772d0d5812c342b (patch)
treeec98b81b64774e8f9c4a6494b3fdf4d86942ed97 /source4/torture
parent0155b5c8439d829c8ced81cd0198830de095cca6 (diff)
downloadsamba-afe300cb527c19cffa8667db4772d0d5812c342b.tar.gz
samba-afe300cb527c19cffa8667db4772d0d5812c342b.tar.bz2
samba-afe300cb527c19cffa8667db4772d0d5812c342b.zip
s4-smbtorture: fix spoolss enum tests.
Guenther
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/rpc/samba3rpc.c6
-rw-r--r--source4/torture/rpc/spoolss.c65
-rw-r--r--source4/torture/rpc/spoolss_win.c14
3 files changed, 58 insertions, 27 deletions
diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c
index d4bcb4919c..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)) {
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index d0252d8d69..2592cc310d 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");
@@ -238,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);
@@ -257,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");
@@ -353,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);
@@ -370,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");
@@ -422,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);
@@ -440,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");
@@ -491,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);
@@ -509,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");
@@ -702,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");
@@ -719,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);
@@ -829,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");
@@ -843,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");
@@ -950,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;
@@ -957,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");
@@ -967,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);
@@ -1122,10 +1138,12 @@ static bool test_GetPrinterData(struct torture_context *tctx,
{
NTSTATUS status;
struct spoolss_GetPrinterData r;
+ uint32_t needed;
r.in.handle = handle;
r.in.value_name = value_name;
r.in.offered = 0;
+ r.out.needed = &needed;
torture_comment(tctx, "Testing GetPrinterData\n");
@@ -1133,7 +1151,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");
@@ -1558,12 +1576,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);
@@ -1571,10 +1591,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);
}
@@ -1669,11 +1689,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);
@@ -1682,10 +1705,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 647f13e9bc..cddba3d38c 100644
--- a/source4/torture/rpc/spoolss_win.c
+++ b/source4/torture/rpc/spoolss_win.c
@@ -155,11 +155,13 @@ static bool test_GetPrinterData(struct torture_context *tctx,
{
NTSTATUS status;
struct spoolss_GetPrinterData gpd;
+ uint32_t needed;
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;
status = dcerpc_spoolss_GetPrinterData(p, tctx, &gpd);
torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed.");
@@ -182,20 +184,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.");
}
@@ -309,6 +313,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");
@@ -316,14 +321,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");
}