summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/librpc/idl/spoolss.idl158
-rw-r--r--source4/librpc/ndr/ndr_spoolss_buf.c74
-rw-r--r--source4/rpc_server/spoolss/dcesrv_spoolss.c44
-rw-r--r--source4/torture/rpc/spoolss.c140
4 files changed, 198 insertions, 218 deletions
diff --git a/source4/librpc/idl/spoolss.idl b/source4/librpc/idl/spoolss.idl
index 3a3921b261..2b557d25d2 100644
--- a/source4/librpc/idl/spoolss.idl
+++ b/source4/librpc/idl/spoolss.idl
@@ -254,8 +254,10 @@
[in] spoolss_EnumPrinterFlags flags,
[in] unistr *server,
[in] uint32 level,
- [in,out] DATA_BLOB *buffer,
- [in,out,ref] uint32 *buf_size,
+ [in] DATA_BLOB *buffer,
+ [in] uint32 offered,
+ [out] DATA_BLOB *info,
+ [out] uint32 needed,
[out] uint32 count
);
[public,noopnum,noprint] void __spoolss_EnumPrinters(
@@ -268,11 +270,12 @@
[in] unistr *server,
[in] uint32 level,
[in] DATA_BLOB *buffer,
+ [in] uint32 offered,
/* what we have here is a subcontext containing an array of no discriminant unions
* and the array has no size in front
*/
[out,switch_is(level),size_is(count)] spoolss_PrinterInfo *info,
- [in,out,ref] uint32 *buf_size,
+ [out] uint32 needed,
[out] uint32 count
);
@@ -342,23 +345,26 @@
/* Function: 0x03 */
WERROR spoolss_GetJob(
[in,ref] policy_handle *handle,
- [in] uint32 job_id,
- [in] uint32 level,
- [in] DATA_BLOB *buffer,
+ [in] uint32 job_id,
+ [in] uint32 level,
+ [in] DATA_BLOB *buffer,
+ [in] uint32 offered,
[out,subcontext(4),switch_is(level)] spoolss_JobInfo *info,
- [in,out,ref] uint32 *buf_size
+ [out] uint32 needed
);
/******************/
/* Function: 0x04 */
[public,noopnum,noprint] WERROR _spoolss_EnumJobs(
[in,ref] policy_handle *handle,
- [in] uint32 firstjob,
- [in] uint32 numjobs,
- [in] uint32 level,
- [in,out] DATA_BLOB *buffer,
- [in,out,ref] uint32 *buf_size,
- [out] uint32 count
+ [in] uint32 firstjob,
+ [in] uint32 numjobs,
+ [in] uint32 level,
+ [in] DATA_BLOB *buffer,
+ [in] uint32 offered,
+ [out] DATA_BLOB *info,
+ [out] uint32 needed,
+ [out] uint32 count
);
[public,noopnum,noprint] void __spoolss_EnumJobs(
[in] uint32 level,
@@ -371,8 +377,9 @@
[in] uint32 numjobs,
[in] uint32 level,
[in] DATA_BLOB *buffer,
+ [in] uint32 offered,
[out,switch_is(level),size_is(count)] spoolss_JobInfo *info,
- [in,out,ref] uint32 *buf_size,
+ [out] uint32 needed,
[out] uint32 count
);
@@ -429,11 +436,12 @@
/******************/
/* Function: 0x08 */
WERROR spoolss_GetPrinter(
- [in,ref] policy_handle *handle,
- [in] uint32 level,
- [in] DATA_BLOB *buffer,
+ [in,ref] policy_handle *handle,
+ [in] uint32 level,
+ [in] DATA_BLOB *buffer,
+ [in] uint32 offered,
[out,subcontext(4),switch_is(level)] spoolss_PrinterInfo *info,
- [in,out,ref] uint32 *buf_size
+ [out] uint32 needed
);
/******************/
@@ -536,8 +544,10 @@
[in] unistr *server,
[in] unistr *environment,
[in] uint32 level,
- [in,out] DATA_BLOB *buffer,
- [in,out,ref] uint32 *buf_size,
+ [in] DATA_BLOB *buffer,
+ [in] uint32 offered,
+ [out] DATA_BLOB *info,
+ [out] uint32 needed,
[out] uint32 count
);
[public,noopnum,noprint] void __spoolss_EnumPrinterDrivers(
@@ -550,8 +560,9 @@
[in] unistr *environment,
[in] uint32 level,
[in] DATA_BLOB *buffer,
+ [in] uint32 offered,
[out,switch_is(level),size_is(count)] spoolss_DriverInfo *info,
- [in,out,ref] uint32 *buf_size,
+ [out] uint32 needed,
[out] uint32 count
);
@@ -594,8 +605,10 @@
[in] unistr *servername,
[in] unistr *environment,
[in] uint32 level,
- [in,out] DATA_BLOB *buffer,
- [in,out,ref] uint32 *buf_size,
+ [in] DATA_BLOB *buffer,
+ [in] uint32 offered,
+ [out] DATA_BLOB *info,
+ [out] uint32 needed,
[out] uint32 count
);
[public,noopnum,noprint] void __spoolss_EnumPrintProcessors(
@@ -608,8 +621,9 @@
[in] unistr *environment,
[in] uint32 level,
[in] DATA_BLOB *buffer,
+ [in] uint32 offered,
[out,switch_is(level),size_is(count)] spoolss_PrintProcessorInfo *info,
- [in,out,ref] uint32 *buf_size,
+ [out] uint32 needed,
[out] uint32 count
);
@@ -712,9 +726,10 @@
[noopnum,nopush,noprint,public] WERROR _spoolss_GetPrinterData(
[in,ref] policy_handle *handle,
[in] unistr value_name,
+ [in] uint32 offered,
[out] spoolss_PrinterDataType type,
[out] DATA_BLOB data,
- [in,out,ref] uint32 *buf_size
+ [out] uint32 needed
);
[noopnum,nopush,noprint,public] void __spoolss_GetPrinterData(
[in] spoolss_PrinterDataType type,
@@ -723,9 +738,10 @@
[nopull] WERROR spoolss_GetPrinterData(
[in,ref] policy_handle *handle,
[in] unistr value_name,
+ [in] uint32 offered,
[out] spoolss_PrinterDataType type,
[out,subcontext(4),switch_is(type)] spoolss_PrinterData data,
- [in,out,ref] uint32 *buf_size
+ [out] uint32 needed
);
/******************/
@@ -735,7 +751,7 @@
[in] unistr value_name,
[in] spoolss_PrinterDataType type,
[in] DATA_BLOB data,
- [in] uint32 _buf_size
+ [in] uint32 _offered
);
[noopnum,nopull,noprint,public] void __spoolss_SetPrinterData(
[in] spoolss_PrinterDataType type,
@@ -746,7 +762,7 @@
[in] unistr value_name,
[in] spoolss_PrinterDataType type,
[in,subcontext(4),switch_is(type)] spoolss_PrinterData data,
- [in,value(ndr_size_spoolss_PrinterData(&data,type,flags))] uint32 _buf_size
+ [in,value(ndr_size_spoolss_PrinterData(&data,type,flags))] uint32 _offered
);
/******************/
@@ -818,8 +834,9 @@
[in] unistr form_name,
[in] uint32 level,
[in] DATA_BLOB *buffer,
+ [in] uint32 offered,
[out,subcontext(4),switch_is(level)] spoolss_FormInfo *info,
- [in,out,ref] uint32 *buf_size
+ [out] uint32 needed
);
typedef struct {
@@ -851,10 +868,12 @@
/* Function: 0x22 */
[public,noopnum,noprint] WERROR _spoolss_EnumForms(
[in,ref] policy_handle *handle,
- [in] uint32 level,
- [in,out] DATA_BLOB *buffer,
- [in,out,ref] uint32 *buf_size,
- [out] uint32 count
+ [in] uint32 level,
+ [in] DATA_BLOB *buffer,
+ [in] uint32 offered,
+ [out] DATA_BLOB *info,
+ [out] uint32 needed,
+ [out] uint32 count
);
[public,noopnum,noprint] void __spoolss_EnumForms(
[in] uint32 level,
@@ -863,10 +882,11 @@
);
[nopull,nopush] WERROR spoolss_EnumForms(
[in,ref] policy_handle *handle,
- [in] uint32 level,
- [in] DATA_BLOB *buffer,
+ [in] uint32 level,
+ [in] DATA_BLOB *buffer,
+ [in] uint32 offered,
[out,switch_is(level),size_is(count)] spoolss_FormInfo *info,
- [in,out,ref] uint32 *buf_size,
+ [out] uint32 needed,
[out] uint32 count
);
@@ -901,8 +921,10 @@
[public,noopnum,noprint] WERROR _spoolss_EnumPorts(
[in] unistr *servername,
[in] uint32 level,
- [in,out] DATA_BLOB *buffer,
- [in,out,ref] uint32 *buf_size,
+ [in] DATA_BLOB *buffer,
+ [in] uint32 offered,
+ [out] DATA_BLOB *info,
+ [out] uint32 needed,
[out] uint32 count
);
[public,noopnum,noprint] void __spoolss_EnumPorts(
@@ -914,8 +936,9 @@
[in] unistr *servername,
[in] uint32 level,
[in] DATA_BLOB *buffer,
+ [in] uint32 offered,
[out,switch_is(level),size_is(count)] spoolss_PortInfo *info,
- [in,out,ref] uint32 *buf_size,
+ [out] uint32 needed,
[out] uint32 count
);
@@ -940,8 +963,10 @@
[public,noopnum,noprint] WERROR _spoolss_EnumMonitors(
[in] unistr *servername,
[in] uint32 level,
- [in,out] DATA_BLOB *buffer,
- [in,out,ref] uint32 *buf_size,
+ [in] DATA_BLOB *buffer,
+ [in] uint32 offered,
+ [out] DATA_BLOB *info,
+ [out] uint32 needed,
[out] uint32 count
);
[public,noopnum,noprint] void __spoolss_EnumMonitors(
@@ -953,8 +978,9 @@
[in] unistr *servername,
[in] uint32 level,
[in] DATA_BLOB *buffer,
+ [in] uint32 offered,
[out,switch_is(level),size_is(count)] spoolss_MonitorInfo *info,
- [in,out,ref] uint32 *buf_size,
+ [out] uint32 needed,
[out] uint32 count
);
@@ -1047,14 +1073,16 @@
/* Function: 0x35 */
WERROR spoolss_GetPrinterDriver2(
[in,ref] policy_handle *handle,
- [in] unistr *architecture,
- [in] uint32 level,
- [in,out] DATA_BLOB *buffer,
- [in,out,ref] uint32 *buf_size,
- [in] uint32 client_major_version,
- [in] uint32 client_minor_version,
- [out] uint32 server_major_version,
- [out] uint32 server_minor_version
+ [in] unistr *architecture,
+ [in] uint32 level,
+ [in] DATA_BLOB *buffer,
+ [in] uint32 offered,
+ [in] uint32 client_major_version,
+ [in] uint32 client_minor_version,
+ [out] DATA_BLOB *info,
+ [out] uint32 needed,
+ [out] uint32 server_major_version,
+ [out] uint32 server_minor_version
);
/******************/
@@ -1236,32 +1264,34 @@
/* Function: 0x4d */
WERROR spoolss_SetPrinterDataEx(
[in,ref] policy_handle *handle,
- [in] unistr key_name,
- [in] unistr value_name,
- [in] uint32 type,
- [in] DATA_BLOB buffer,
- [in,out,ref] uint32 *buf_size
+ [in] unistr key_name,
+ [in] unistr value_name,
+ [in] uint32 type,
+ [in] DATA_BLOB buffer,
+ [in] uint32 offered
);
/******************/
/* Function: 0x4e */
WERROR spoolss_GetPrinterDataEx(
[in,ref] policy_handle *handle,
- [in] unistr key_name,
- [in] unistr value_name,
- [out] uint32 type,
- [out] DATA_BLOB buffer,
- [in,out,ref] uint32 *buf_size
+ [in] unistr key_name,
+ [in] unistr value_name,
+ [in] uint32 offered,
+ [out] uint32 type,
+ [out] DATA_BLOB buffer,
+ [out] uint32 needed
);
/******************/
/* Function: 0x4f */
WERROR spoolss_EnumPrinterDataEx(
[in,ref] policy_handle *handle,
- [in] unistr key_name,
- [out] DATA_BLOB buffer,
- [in,out] uint32 buf_size,
- [out] uint32 count
+ [in] unistr key_name,
+ [in] uint32 offered,
+ [out] DATA_BLOB buffer,
+ [out] uint32 needed,
+ [out] uint32 count
);
/******************/
diff --git a/source4/librpc/ndr/ndr_spoolss_buf.c b/source4/librpc/ndr/ndr_spoolss_buf.c
index 6ecaa49fcf..621ddfd081 100644
--- a/source4/librpc/ndr/ndr_spoolss_buf.c
+++ b/source4/librpc/ndr/ndr_spoolss_buf.c
@@ -28,7 +28,7 @@
#define NDR_SPOOLSS_PUSH_ENUM_IN(fn) do { \
_r.in.level = r->in.level;\
_r.in.buffer = r->in.buffer;\
- _r.in.buf_size = r->in.buf_size;\
+ _r.in.offered = r->in.offered;\
NDR_CHECK(ndr_push__##fn(ndr, flags, &_r));\
} while(0)
@@ -36,9 +36,9 @@
struct ndr_push *_ndr_info;\
_r.in.level = r->in.level;\
_r.in.buffer = r->in.buffer;\
- _r.in.buf_size = r->in.buf_size;\
- _r.out.buffer = NULL;\
- _r.out.buf_size = r->out.buf_size;\
+ _r.in.offered = r->in.offered;\
+ _r.out.info = NULL;\
+ _r.out.needed = r->out.needed;\
_r.out.count = r->out.count;\
_r.out.result = r->out.result;\
if (r->out.info) {\
@@ -51,12 +51,12 @@
__r.in.count = r->out.count;\
__r.out.info = r->out.info;\
NDR_CHECK(ndr_push___##fn(_ndr_info, flags, &__r)); \
- if (*r->in.buf_size > _ndr_info->offset) {\
- uint32_t _padding_len = *r->in.buf_size - _ndr_info->offset;\
+ if (r->in.offered > _ndr_info->offset) {\
+ uint32_t _padding_len = r->in.offered - _ndr_info->offset;\
NDR_CHECK(ndr_push_zero(_ndr_info, _padding_len));\
}\
_data_blob_info = ndr_push_blob(_ndr_info);\
- _r.out.buffer = &_data_blob_info;\
+ _r.out.info = &_data_blob_info;\
}\
NDR_CHECK(ndr_push__##fn(ndr, flags, &_r));\
} while(0)
@@ -78,36 +78,37 @@
NDR_CHECK(ndr_pull__##fn(ndr, flags, &_r));\
r->in.level = _r.in.level;\
r->in.buffer = _r.in.buffer;\
- r->in.buf_size = _r.in.buf_size;\
- r->out.buf_size = _r.out.buf_size;\
+ r->in.offered = _r.in.offered;\
+ r->out.needed = _r.out.needed;\
} while(0)
#define NDR_SPOOLSS_PULL_ENUM_OUT(fn) do { \
- struct ndr_pull *_ndr_info;\
_r.in.level = r->in.level;\
_r.in.buffer = r->in.buffer;\
- _r.in.buf_size = r->in.buf_size;\
- _r.out.buf_size = r->out.buf_size;\
+ _r.in.offered = r->in.offered;\
+ _r.out.needed = r->out.needed;\
NDR_CHECK(ndr_pull__##fn(ndr, flags, &_r));\
r->out.info = NULL;\
- r->out.buf_size = _r.out.buf_size;\
+ r->out.needed = _r.out.needed;\
r->out.count = _r.out.count;\
r->out.result = _r.out.result;\
- if (_r.out.buffer) {\
- struct __##fn __r;\
- _ndr_info = ndr_pull_init_blob(_r.out.buffer, ndr);\
+ if (_r.out.info) {\
+ struct ndr_pull *_ndr_info = ndr_pull_init_blob(_r.out.info, ndr);\
if (!_ndr_info) return NT_STATUS_NO_MEMORY;\
_ndr_info->flags= ndr->flags;\
- if (*r->out.buf_size != _ndr_info->data_size) {\
+ if (r->in.offered != _ndr_info->data_size) {\
return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,\
- "SPOOLSS Buffer: buf_size[%u] doesn't match length of buffer[%u]",\
- *r->out.buf_size, _ndr_info->data_size);\
+ "SPOOLSS Buffer: offered[%u] doesn't match length of buffer[%u]",\
+ r->in.offered, _ndr_info->data_size);\
+ }\
+ if (r->out.needed <= _ndr_info->data_size) {\
+ struct __##fn __r;\
+ __r.in.level = r->in.level;\
+ __r.in.count = r->out.count;\
+ __r.out.info = NULL;\
+ NDR_CHECK(ndr_pull___##fn(_ndr_info, flags, &__r));\
+ r->out.info = __r.out.info;\
}\
- __r.in.level = r->in.level;\
- __r.in.count = r->out.count;\
- __r.out.info = NULL;\
- NDR_CHECK(ndr_pull___##fn(_ndr_info, flags, &__r));\
- r->out.info = __r.out.info;\
}\
} while(0)
@@ -372,30 +373,33 @@ NTSTATUS ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct
_r.in.handle = r->in.handle;
_r.in.value_name= r->in.value_name;
- _r.in.buf_size = r->in.buf_size;
+ _r.in.offered = r->in.offered;
_r.out.type = r->out.type;
_r.out.data = data_blob(NULL,0),
- _r.out.buf_size = r->out.buf_size;
+ _r.out.needed = r->out.needed;
NDR_CHECK(ndr_pull__spoolss_GetPrinterData(ndr, flags, &_r));
r->in.handle = _r.in.handle;
r->in.value_name= _r.in.value_name;
- r->in.buf_size = _r.in.buf_size;
- r->out.buf_size = _r.out.buf_size;
+ r->in.offered = _r.in.offered;
+ r->out.needed = _r.out.needed;
}
if (flags & NDR_OUT) {
_r.in.handle = r->in.handle;
_r.in.value_name= r->in.value_name;
- _r.in.buf_size = r->in.buf_size;
+ _r.in.offered = r->in.offered;
_r.out.type = r->out.type;
_r.out.data = data_blob(NULL,0),
- _r.out.buf_size = r->out.buf_size;
+ _r.out.needed = r->out.needed;
_r.out.result = r->out.result;
NDR_CHECK(ndr_pull__spoolss_GetPrinterData(ndr, flags, &_r));
r->out.type = _r.out.type;
ZERO_STRUCT(r->out.data);
- r->out.buf_size = _r.out.buf_size;
+ r->out.needed = _r.out.needed;
r->out.result = _r.out.result;
- if (_r.out.data.length > 0) {
+ if (_r.out.data.length != r->in.offered) {
+ /* TODO: ndr_pull_error(...) */
+ }
+ if (_r.out.data.length > 0 && r->out.needed <= _r.out.data.length) {
struct __spoolss_GetPrinterData __r;
struct ndr_pull *_ndr_data = ndr_pull_init_blob(&_r.out.data, ndr);
if (!_ndr_data) return NT_STATUS_NO_MEMORY;
@@ -431,13 +435,13 @@ NTSTATUS ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, struct
NDR_CHECK(ndr_push___spoolss_SetPrinterData(_ndr_data, NDR_OUT, &__r));
_data_blob_data = ndr_push_blob(_ndr_data);
- r->in._buf_size = _data_blob_data.length;
+ r->in._offered = _data_blob_data.length;
_r.in.handle = r->in.handle;
_r.in.value_name= r->in.value_name;
_r.in.type = r->in.type;
_r.in.data = _data_blob_data;
- _r.in._buf_size = r->in._buf_size;
+ _r.in._offered = r->in._offered;
_r.out.result = r->out.result;
NDR_CHECK(ndr_push__spoolss_SetPrinterData(ndr, flags, &_r));
}
@@ -446,7 +450,7 @@ NTSTATUS ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, struct
_r.in.value_name= r->in.value_name;
_r.in.type = r->in.type;
_r.in.data = data_blob(NULL,0),
- _r.in._buf_size = r->in._buf_size;
+ _r.in._offered = r->in._offered;
_r.out.result = r->out.result;
NDR_CHECK(ndr_push__spoolss_SetPrinterData(ndr, flags, &_r));
}
diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c
index d92d6de55a..b226816436 100644
--- a/source4/rpc_server/spoolss/dcesrv_spoolss.c
+++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c
@@ -32,7 +32,7 @@
#define SPOOLSS_BUFFER_SIZE(fn,level,count,info) \
ndr_size_##fn##_info(dce_call, level, count, info)
-#define SPOOLSS_BUFFER_OK(val_true,val_false) ((*r->in.buf_size >= *r->out.buf_size)?val_true:val_false)
+#define SPOOLSS_BUFFER_OK(val_true,val_false) ((r->in.offered >= r->out.needed)?val_true:val_false)
/*
spoolss_EnumPrinters
@@ -46,8 +46,6 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT
int i;
union spoolss_PrinterInfo *info;
- *r->out.buf_size = 0;
-
spoolss_ctx = spoolssdb_connect();
W_ERROR_HAVE_NO_MEMORY(spoolss_ctx);
@@ -74,7 +72,7 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT
info[i].info1.comment = samdb_result_string(msgs[i], "comment", NULL);
}
- *r->out.buf_size= SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinters, r->in.level, count, info);
+ r->out.needed = SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinters, r->in.level, count, info);
r->out.info = SPOOLSS_BUFFER_OK(info, NULL);
r->out.count = SPOOLSS_BUFFER_OK(count, 0);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
@@ -122,7 +120,7 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT
info[i].info2.cjobs = samdb_result_uint(msgs[i], "cjobs", 0);
info[i].info2.averageppm = samdb_result_uint(msgs[i], "averageppm", 0);
}
- *r->out.buf_size= SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinters, r->in.level, count, info);
+ r->out.needed = SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinters, r->in.level, count, info);
r->out.info = SPOOLSS_BUFFER_OK(info, NULL);
r->out.count = SPOOLSS_BUFFER_OK(count, 0);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
@@ -136,7 +134,7 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT
info[i].info4.attributes = samdb_result_uint(msgs[i], "attributes", 0);
}
- *r->out.buf_size= SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinters, r->in.level, count, info);
+ r->out.needed = SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinters, r->in.level, count, info);
r->out.info = SPOOLSS_BUFFER_OK(info, NULL);
r->out.count = SPOOLSS_BUFFER_OK(count, 0);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
@@ -152,7 +150,7 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT
info[i].info5.device_not_selected_timeout = samdb_result_uint(msgs[i], "device_not_selected_timeout", 0);
info[i].info5.transmission_retry_timeout = samdb_result_uint(msgs[i], "transmission_retry_timeout", 0);
}
- *r->out.buf_size= SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinters, r->in.level, count, info);
+ r->out.needed = SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinters, r->in.level, count, info);
r->out.info = SPOOLSS_BUFFER_OK(info, NULL);
r->out.count = SPOOLSS_BUFFER_OK(count, 0);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
@@ -221,8 +219,6 @@ static WERROR spoolss_GetJob(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem
static WERROR spoolss_EnumJobs(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct spoolss_EnumJobs *r)
{
- *r->out.buf_size = 0;
-
return WERR_OK;
}
@@ -287,8 +283,6 @@ static WERROR spoolss_EnumPrinterDrivers(struct dcesrv_call_state *dce_call, TAL
int count;
int i;
- *r->out.buf_size = 0;
-
count = 0;
if (count == 0) return WERR_OK;
@@ -301,42 +295,42 @@ static WERROR spoolss_EnumPrinterDrivers(struct dcesrv_call_state *dce_call, TAL
case 1:
for (i=0; i < count; i++) {
}
- *r->out.buf_size= SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinterDrivers, r->in.level, count, info);
+ r->out.needed = SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinterDrivers, r->in.level, count, info);
r->out.info = SPOOLSS_BUFFER_OK(info, NULL);
r->out.count = SPOOLSS_BUFFER_OK(count, 0);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
case 2:
for (i=0; i < count; i++) {
}
- *r->out.buf_size= SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinterDrivers, r->in.level, count, info);
+ r->out.needed = SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinterDrivers, r->in.level, count, info);
r->out.info = SPOOLSS_BUFFER_OK(info, NULL);
r->out.count = SPOOLSS_BUFFER_OK(count, 0);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
case 3:
for (i=0; i < count; i++) {
}
- *r->out.buf_size= SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinterDrivers, r->in.level, count, info);
+ r->out.needed = SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinterDrivers, r->in.level, count, info);
r->out.info = SPOOLSS_BUFFER_OK(info, NULL);
r->out.count = SPOOLSS_BUFFER_OK(count, 0);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
case 4:
for (i=0; i < count; i++) {
}
- *r->out.buf_size= SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinterDrivers, r->in.level, count, info);
+ r->out.needed = SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinterDrivers, r->in.level, count, info);
r->out.info = SPOOLSS_BUFFER_OK(info, NULL);
r->out.count = SPOOLSS_BUFFER_OK(count, 0);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
case 5:
for (i=0; i < count; i++) {
}
- *r->out.buf_size= SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinterDrivers, r->in.level, count, info);
+ r->out.needed = SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinterDrivers, r->in.level, count, info);
r->out.info = SPOOLSS_BUFFER_OK(info, NULL);
r->out.count = SPOOLSS_BUFFER_OK(count, 0);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
case 6:
for (i=0; i < count; i++) {
}
- *r->out.buf_size= SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinterDrivers, r->in.level, count, info);
+ r->out.needed = SPOOLSS_BUFFER_SIZE(spoolss_EnumPrinterDrivers, r->in.level, count, info);
r->out.info = SPOOLSS_BUFFER_OK(info, NULL);
r->out.count = SPOOLSS_BUFFER_OK(count, 0);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
@@ -392,8 +386,6 @@ static WERROR spoolss_AddPrintProcessor(struct dcesrv_call_state *dce_call, TALL
static WERROR spoolss_EnumPrintProcessors(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct spoolss_EnumPrintProcessors *r)
{
- *r->out.buf_size = 0;
-
return WERR_OK;
}
@@ -558,7 +550,7 @@ static WERROR spoolss_GetPrinterData(struct dcesrv_call_state *dce_call, TALLOC_
}
if (W_ERROR_IS_OK(status)) {
- *r->out.buf_size = ndr_size_spoolss_PrinterData(&data, type, 0);
+ r->out.needed = ndr_size_spoolss_PrinterData(&data, type, 0);
r->out.type = SPOOLSS_BUFFER_OK(type, SPOOLSS_PRINTER_DATA_TYPE_NULL);
r->out.data = SPOOLSS_BUFFER_OK(data, data);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_MORE_DATA);
@@ -659,8 +651,6 @@ static WERROR spoolss_EnumForms(struct dcesrv_call_state *dce_call, TALLOC_CTX *
int i;
struct dcesrv_handle *h;
- *r->out.buf_size = 0;
-
DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY);
count = 1;
@@ -687,7 +677,7 @@ static WERROR spoolss_EnumForms(struct dcesrv_call_state *dce_call, TALLOC_CTX *
info[i].info1.area.right = 30;
info[i].info1.area.bottom = 40;
}
- *r->out.buf_size= SPOOLSS_BUFFER_SIZE(spoolss_EnumForms, r->in.level, count, info);
+ r->out.needed = SPOOLSS_BUFFER_SIZE(spoolss_EnumForms, r->in.level, count, info);
r->out.info = SPOOLSS_BUFFER_OK(info, NULL);
r->out.count = SPOOLSS_BUFFER_OK(count, 0);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
@@ -707,8 +697,6 @@ static WERROR spoolss_EnumPorts(struct dcesrv_call_state *dce_call, TALLOC_CTX *
int count;
int i;
- *r->out.buf_size = 0;
-
count = 1;
if (count == 0) return WERR_OK;
@@ -723,7 +711,7 @@ static WERROR spoolss_EnumPorts(struct dcesrv_call_state *dce_call, TALLOC_CTX *
info[i].info1.port_name = talloc_strdup(mem_ctx, "Samba Printer Port");
W_ERROR_HAVE_NO_MEMORY(info[i].info1.port_name);
}
- *r->out.buf_size= SPOOLSS_BUFFER_SIZE(spoolss_EnumPorts, r->in.level, count, info);
+ r->out.needed = SPOOLSS_BUFFER_SIZE(spoolss_EnumPorts, r->in.level, count, info);
r->out.info = SPOOLSS_BUFFER_OK(info, NULL);
r->out.count = SPOOLSS_BUFFER_OK(count, 0);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
@@ -741,7 +729,7 @@ static WERROR spoolss_EnumPorts(struct dcesrv_call_state *dce_call, TALLOC_CTX *
info[i].info2.port_type = SPOOLSS_PORT_TYPE_WRITE;
info[i].info2.reserved = 0;
}
- *r->out.buf_size= SPOOLSS_BUFFER_SIZE(spoolss_EnumPorts, r->in.level, count, info);
+ r->out.needed = SPOOLSS_BUFFER_SIZE(spoolss_EnumPorts, r->in.level, count, info);
r->out.info = SPOOLSS_BUFFER_OK(info, NULL);
r->out.count = SPOOLSS_BUFFER_OK(count, 0);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
@@ -757,8 +745,6 @@ static WERROR spoolss_EnumPorts(struct dcesrv_call_state *dce_call, TALLOC_CTX *
static WERROR spoolss_EnumMonitors(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct spoolss_EnumMonitors *r)
{
- *r->out.buf_size = 0;
-
return WERR_OK;
}
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 61fda796fe..7ae9291cf0 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -132,14 +132,11 @@ static BOOL test_EnumPorts(struct test_spoolss_context *ctx)
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
DATA_BLOB blob;
- uint32_t buf_size = 0;
r.in.servername = "";
r.in.level = level;
r.in.buffer = NULL;
- buf_size = 0;
- r.in.buf_size = &buf_size;
- r.out.buf_size = &buf_size;
+ r.in.offered = 0;
printf("Testing EnumPorts level %u\n", r.in.level);
@@ -160,9 +157,10 @@ static BOOL test_EnumPorts(struct test_spoolss_context *ctx)
continue;
}
- blob = data_blob_talloc(ctx, NULL, buf_size);
+ blob = data_blob_talloc(ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_EnumPorts(ctx->p, ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
@@ -224,15 +222,12 @@ static BOOL test_EnumPrinterDrivers(struct test_spoolss_context *ctx)
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
DATA_BLOB blob;
- uint32_t buf_size = 0;
r.in.server = "";
r.in.environment = "Windows NT x86";
r.in.level = level;
r.in.buffer = NULL;
- buf_size = 0;
- r.in.buf_size = &buf_size;
- r.out.buf_size = &buf_size;
+ r.in.offered = 0;
printf("Testing EnumPrinterDrivers level %u\n", r.in.level);
@@ -253,9 +248,10 @@ static BOOL test_EnumPrinterDrivers(struct test_spoolss_context *ctx)
continue;
}
- blob = data_blob_talloc(ctx, NULL, buf_size);
+ blob = data_blob_talloc(ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_EnumPrinterDrivers(ctx->p, ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
@@ -361,14 +357,11 @@ static BOOL test_EnumMonitors(struct test_spoolss_context *ctx)
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
DATA_BLOB blob;
- uint32_t buf_size = 0;
r.in.servername = "";
r.in.level = level;
r.in.buffer = NULL;
- buf_size = 0;
- r.in.buf_size = &buf_size;
- r.out.buf_size = &buf_size;
+ r.in.offered = 0;
printf("Testing EnumMonitors level %u\n", r.in.level);
@@ -389,9 +382,10 @@ static BOOL test_EnumMonitors(struct test_spoolss_context *ctx)
continue;
}
- blob = data_blob_talloc(ctx, NULL, buf_size);
+ blob = data_blob_talloc(ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_EnumMonitors(ctx->p, ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
@@ -453,15 +447,12 @@ static BOOL test_EnumPrintProcessors(struct test_spoolss_context *ctx)
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
DATA_BLOB blob;
- uint32_t buf_size = 0;
r.in.servername = "";
r.in.environment = "Windows NT x86";
r.in.level = level;
r.in.buffer = NULL;
- buf_size = 0;
- r.in.buf_size = &buf_size;
- r.out.buf_size = &buf_size;
+ r.in.offered = 0;
printf("Testing EnumPrintProcessors level %u\n", r.in.level);
@@ -482,9 +473,10 @@ static BOOL test_EnumPrintProcessors(struct test_spoolss_context *ctx)
continue;
}
- blob = data_blob_talloc(ctx, NULL, buf_size);
+ blob = data_blob_talloc(ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_EnumPrintProcessors(ctx->p, ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
@@ -545,14 +537,12 @@ static BOOL test_EnumPrinters(struct test_spoolss_context *ctx)
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];
DATA_BLOB blob;
- uint32_t buf_size = 0;
r.in.flags = PRINTER_ENUM_LOCAL;
r.in.server = "";
r.in.level = level;
r.in.buffer = NULL;
- r.in.buf_size = &buf_size;
- r.out.buf_size = &buf_size;
+ r.in.offered = 0;
printf("\nTesting EnumPrinters level %u\n", r.in.level);
@@ -573,9 +563,11 @@ static BOOL test_EnumPrinters(struct test_spoolss_context *ctx)
continue;
}
- blob = data_blob_talloc(ctx, NULL, buf_size);
+ blob = data_blob_talloc(ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
+ r.in.offered = r.out.needed;
+
status = dcerpc_spoolss_EnumPrinters(ctx->p, ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("dcerpc_spoolss_EnumPrinters failed - %s\n", nt_errstr(status));
@@ -684,12 +676,10 @@ static BOOL test_GetPrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
BOOL ret = True;
for (i=0;i<ARRAY_SIZE(levels);i++) {
- uint32_t buf_size = 0;
r.in.handle = handle;
r.in.level = levels[i];
r.in.buffer = NULL;
- r.in.buf_size = &buf_size;
- r.out.buf_size = &buf_size;
+ r.in.offered = 0;
printf("Testing GetPrinter level %u\n", r.in.level);
@@ -701,9 +691,10 @@ static BOOL test_GetPrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, buf_size);
+ DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_GetPrinter(p, mem_ctx, &r);
}
@@ -712,7 +703,7 @@ static BOOL test_GetPrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
ret = False;
continue;
}
-
+
if (!W_ERROR_IS_OK(r.out.result)) {
printf("GetPrinter failed - %s\n",
win_errstr(r.out.result));
@@ -751,30 +742,26 @@ static BOOL test_GetForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
{
NTSTATUS status;
struct spoolss_GetForm r;
- uint32_t buf_size;
r.in.handle = handle;
r.in.form_name = form_name;
r.in.level = 1;
r.in.buffer = NULL;
- buf_size = 0;
- r.in.buf_size = r.out.buf_size = &buf_size;
+ r.in.offered = 0;
printf("Testing GetForm\n");
status = dcerpc_spoolss_GetForm(p, mem_ctx, &r);
-
if (!NT_STATUS_IS_OK(status)) {
printf("GetForm failed - %s\n", nt_errstr(status));
return False;
}
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, buf_size);
-
+ DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
-
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_GetForm(p, mem_ctx, &r);
if (!r.out.info) {
@@ -791,31 +778,27 @@ static BOOL test_EnumForms(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
{
NTSTATUS status;
struct spoolss_EnumForms r;
- uint32_t buf_size;
r.in.handle = handle;
r.in.level = 1;
r.in.buffer = NULL;
- buf_size = 0;
- r.in.buf_size = &buf_size;
- r.out.buf_size = &buf_size;
+ r.in.offered = 0;
printf("Testing EnumForms\n");
status = dcerpc_spoolss_EnumForms(p, mem_ctx, &r);
-
if (!NT_STATUS_IS_OK(status)) {
printf("EnumForms failed - %s\n", nt_errstr(status));
return False;
}
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, buf_size);
union spoolss_FormInfo *info;
int j;
-
+ DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_EnumForms(p, mem_ctx, &r);
@@ -946,15 +929,12 @@ static BOOL test_EnumPorts_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
struct spoolss_EnumPorts r;
- uint32_t buf_size;
r.in.servername = talloc_asprintf(mem_ctx, "\\\\%s",
dcerpc_server_name(p));
r.in.level = 2;
r.in.buffer = NULL;
- buf_size = 0;
- r.in.buf_size = &buf_size;
- r.out.buf_size = &buf_size;
+ r.in.offered = 0;
printf("Testing EnumPorts\n");
@@ -966,13 +946,12 @@ static BOOL test_EnumPorts_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
}
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, buf_size);
-
+ DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_EnumPorts(p, mem_ctx, &r);
-
if (!NT_STATUS_IS_OK(status)) {
printf("EnumPorts failed - %s\n", nt_errstr(status));
return False;
@@ -1025,29 +1004,26 @@ static BOOL test_GetJob(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
{
NTSTATUS status;
struct spoolss_GetJob r;
- uint32_t buf_size;
r.in.handle = handle;
r.in.job_id = job_id;
r.in.level = 1;
r.in.buffer = NULL;
- buf_size = 0;
- r.in.buf_size = r.out.buf_size = &buf_size;
+ r.in.offered = 0;
printf("Testing GetJob\n");
status = dcerpc_spoolss_GetJob(p, mem_ctx, &r);
-
if (!NT_STATUS_IS_OK(status)) {
printf("GetJob failed - %s\n", nt_errstr(status));
return False;
}
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, buf_size);
-
+ DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_GetJob(p, mem_ctx, &r);
@@ -1091,16 +1067,13 @@ static BOOL test_EnumJobs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
{
NTSTATUS status;
struct spoolss_EnumJobs r;
- uint32_t buf_size;
r.in.handle = handle;
r.in.firstjob = 0;
r.in.numjobs = 0xffffffff;
r.in.level = 1;
r.in.buffer = NULL;
- buf_size = 0;
- r.in.buf_size = &buf_size;
- r.out.buf_size = &buf_size;
+ r.in.offered = 0;
printf("Testing EnumJobs\n");
@@ -1112,12 +1085,12 @@ static BOOL test_EnumJobs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, buf_size);
union spoolss_JobInfo *info;
int j;
-
+ DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_EnumJobs(p, mem_ctx, &r);
@@ -1313,26 +1286,23 @@ static BOOL test_GetPrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
{
NTSTATUS status;
struct spoolss_GetPrinterData r;
- uint32_t buf_size;
r.in.handle = handle;
r.in.value_name = value_name;
- buf_size = 0;
- r.in.buf_size = r.out.buf_size = &buf_size;
+ r.in.offered = 0;
printf("Testing GetPrinterData\n");
status = dcerpc_spoolss_GetPrinterData(p, mem_ctx, &r);
-
if (!NT_STATUS_IS_OK(status)) {
printf("GetPrinterData failed - %s\n", nt_errstr(status));
return False;
}
if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_GetPrinterData(p, mem_ctx, &r);
-
if (!NT_STATUS_IS_OK(status)) {
printf("GetPrinterData failed - %s\n",
nt_errstr(status));
@@ -1356,13 +1326,11 @@ static BOOL test_GetPrinterDataEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
{
NTSTATUS status;
struct spoolss_GetPrinterDataEx r;
- uint32_t buf_size;
r.in.handle = handle;
r.in.key_name = key_name;
r.in.value_name = value_name;
- buf_size = 0;
- r.in.buf_size = r.out.buf_size = &buf_size;
+ r.in.offered = 0;
printf("Testing GetPrinterDataEx\n");
@@ -1378,9 +1346,9 @@ static BOOL test_GetPrinterDataEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_GetPrinterDataEx(p, mem_ctx, &r);
-
if (!NT_STATUS_IS_OK(status)) {
printf("GetPrinterDataEx failed - %s\n",
nt_errstr(status));
@@ -1453,18 +1421,17 @@ static BOOL test_EnumPrinterDataEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.handle = handle;
r.in.key_name = "PrinterDriverData";
- r.in.buf_size = 0;
+ r.in.offered = 0;
printf("Testing EnumPrinterDataEx\n");
status = dcerpc_spoolss_EnumPrinterDataEx(p, mem_ctx, &r);
-
if (!NT_STATUS_IS_OK(status)) {
printf("EnumPrinterDataEx failed - %s\n", nt_errstr(status));
return False;
}
- r.in.buf_size = r.out.buf_size;
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_EnumPrinterDataEx(p, mem_ctx, &r);
@@ -1822,7 +1789,6 @@ static BOOL test_EnumPrinters_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
BOOL ret = True;
for (i=0;i<ARRAY_SIZE(levels);i++) {
- uint32_t buf_size = 0;
union spoolss_PrinterInfo *info;
int j;
@@ -1830,8 +1796,7 @@ static BOOL test_EnumPrinters_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
r.in.server = "";
r.in.level = levels[i];
r.in.buffer = NULL;
- r.in.buf_size = &buf_size;
- r.out.buf_size = &buf_size;
+ r.in.offered = 0;
printf("\nTesting EnumPrinters level %u\n", r.in.level);
@@ -1843,9 +1808,10 @@ static BOOL test_EnumPrinters_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
}
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, buf_size);
+ DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_EnumPrinters(p, mem_ctx, &r);
}
@@ -1894,27 +1860,25 @@ static BOOL test_GetPrinterDriver2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
{
NTSTATUS status;
struct spoolss_GetPrinterDriver2 r;
- uint32_t buf_size;
r.in.handle = handle;
r.in.architecture = "W32X86";
r.in.level = 1;
- buf_size = 0;
r.in.buffer = NULL;
- r.in.buf_size = r.out.buf_size = &buf_size;
+ r.in.offered = 0;
r.in.client_major_version = 0;
r.in.client_minor_version = 0;
printf("Testing GetPrinterDriver2\n");
status = dcerpc_spoolss_GetPrinterDriver2(p, mem_ctx, &r);
-
if (!NT_STATUS_IS_OK(status)) {
printf("GetPrinterDriver2 failed - %s\n", nt_errstr(status));
return False;
}
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_GetPrinterDriver2(p, mem_ctx, &r);
}
@@ -1943,15 +1907,12 @@ static BOOL test_EnumPrinterDrivers_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_c
BOOL ret = True;
for (i=0;i<ARRAY_SIZE(levels);i++) {
- uint32_t buf_size;
r.in.server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
r.in.environment = "Windows NT x86";
r.in.level = levels[i];
r.in.buffer = NULL;
- buf_size = 0;
- r.in.buf_size = &buf_size;
- r.out.buf_size = &buf_size;
+ r.in.offered = 0;
printf("\nTesting EnumPrinterDrivers level %u\n", r.in.level);
@@ -1965,14 +1926,13 @@ static BOOL test_EnumPrinterDrivers_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_c
}
if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc(
- mem_ctx, NULL, buf_size);
-
+ DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed);
data_blob_clear(&blob);
r.in.buffer = &blob;
+ r.in.offered = r.out.needed;
status = dcerpc_spoolss_EnumPrinterDrivers(p, mem_ctx, &r);
}
-
+
if (!NT_STATUS_IS_OK(status)) {
printf("EnumPrinterDrivers failed - %s\n",
nt_errstr(status));