diff options
Diffstat (limited to 'source4/librpc')
-rw-r--r-- | source4/librpc/idl/spoolss.idl | 2 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_basic.c | 66 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss.c | 4 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss.h | 2 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc.c | 2 |
5 files changed, 72 insertions, 4 deletions
diff --git a/source4/librpc/idl/spoolss.idl b/source4/librpc/idl/spoolss.idl index a78dabd533..586536b69c 100644 --- a/source4/librpc/idl/spoolss.idl +++ b/source4/librpc/idl/spoolss.idl @@ -537,7 +537,7 @@ [in,ref] policy_handle *handle, [in] uint32 enum_index, [in] uint32 value_offered, - [out] DATA_BLOB value, + [out] lstring value, [out] uint32 value_needed, [out] uint32 printerdata_type, [out] DATA_BLOB data, diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index a2f0309acd..fcf64b6790 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -575,6 +575,37 @@ NTSTATUS ndr_pull_nstring(struct ndr_pull *ndr, int ndr_flags, const char **s) } /* + pull a length prefixed UCS2 string +*/ +NTSTATUS ndr_pull_lstring(struct ndr_pull *ndr, int ndr_flags, const char **s) +{ + int ret; + uint32 size; + + if (!(ndr_flags & NDR_SCALARS)) { + return NT_STATUS_OK; + } + + NDR_CHECK(ndr_pull_uint32(ndr, &size)); + if (size == 0) { + *s = NULL; + return NT_STATUS_OK; + } + + NDR_PULL_NEED_BYTES(ndr, size*2); + + ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX, + ndr->data+ndr->offset, + size*2, + (const void **)s); + if (ret == -1) { + return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); + } + ndr->offset += size*2; + return NT_STATUS_OK; +} + +/* push a spoolss style "relative string" */ NTSTATUS ndr_push_nstring(struct ndr_push *ndr, int ndr_flags, const char **s) @@ -596,11 +627,46 @@ NTSTATUS ndr_push_nstring(struct ndr_push *ndr, int ndr_flags, const char **s) return NT_STATUS_OK; } +/* + push a length prefixed ucs2 string +*/ +NTSTATUS ndr_push_lstring(struct ndr_push *ndr, int ndr_flags, const char **s) +{ + uint32 len; + int ret; + + if (!(ndr_flags & NDR_SCALARS)) { + return NT_STATUS_OK; + } + + if (! *s) { + NDR_CHECK(ndr_push_uint32(ndr, 0)); + return NT_STATUS_OK; + } + + len = (strlen_m(*s)+1); + + NDR_CHECK(ndr_push_uint32(ndr, len)); + NDR_PUSH_NEED_BYTES(ndr, len*2); + + ret = push_ucs2(NULL, ndr->data + ndr->offset, *s, len*2, STR_TERMINATE); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad string conversion"); + } + ndr->offset += len*2; + return NT_STATUS_OK; +} + void ndr_print_nstring(struct ndr_print *ndr, const char *name, const char **s) { ndr_print_unistr(ndr, name, *s); } +void ndr_print_lstring(struct ndr_print *ndr, const char *name, const char **s) +{ + ndr_print_unistr(ndr, name, *s); +} + void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) { ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, r.length); diff --git a/source4/librpc/ndr/ndr_spoolss.c b/source4/librpc/ndr/ndr_spoolss.c index cddbf64570..b0d4418af9 100644 --- a/source4/librpc/ndr/ndr_spoolss.c +++ b/source4/librpc/ndr/ndr_spoolss.c @@ -1790,7 +1790,7 @@ NTSTATUS ndr_pull_spoolss_47(struct ndr_pull *ndr, struct spoolss_47 *r) NTSTATUS ndr_pull_spoolss_EnumPrinterData(struct ndr_pull *ndr, struct spoolss_EnumPrinterData *r) { - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, &r->out.value)); + NDR_CHECK(ndr_pull_lstring(ndr, NDR_SCALARS|NDR_BUFFERS, &r->out.value)); NDR_CHECK(ndr_pull_uint32(ndr, &r->out.value_needed)); NDR_CHECK(ndr_pull_uint32(ndr, &r->out.printerdata_type)); NDR_CHECK(ndr_pull_DATA_BLOB(ndr, &r->out.data)); @@ -3663,7 +3663,7 @@ void ndr_print_spoolss_EnumPrinterData(struct ndr_print *ndr, const char *name, if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "spoolss_EnumPrinterData"); ndr->depth++; - ndr_print_DATA_BLOB(ndr, "value", r->out.value); + ndr_print_lstring(ndr, "value", &r->out.value); ndr_print_uint32(ndr, "value_needed", r->out.value_needed); ndr_print_uint32(ndr, "printerdata_type", r->out.printerdata_type); ndr_print_DATA_BLOB(ndr, "data", r->out.data); diff --git a/source4/librpc/ndr/ndr_spoolss.h b/source4/librpc/ndr/ndr_spoolss.h index 6530375fc8..e80c72ca51 100644 --- a/source4/librpc/ndr/ndr_spoolss.h +++ b/source4/librpc/ndr/ndr_spoolss.h @@ -1000,7 +1000,7 @@ struct spoolss_EnumPrinterData { } in; struct { - DATA_BLOB value; + const char * value; uint32 value_needed; uint32 printerdata_type; DATA_BLOB data; diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c index bc5f38aa05..7fa24bb171 100644 --- a/source4/librpc/rpc/dcerpc.c +++ b/source4/librpc/rpc/dcerpc.c @@ -764,6 +764,7 @@ NTSTATUS dcerpc_ndr_request(struct dcerpc_pipe *p, /* retrieve the blob */ request = ndr_push_blob(push); + DEBUG(10,("rpc request data:\n")); dump_data(10, request.data, request.length); /* make the actual dcerpc request */ @@ -778,6 +779,7 @@ NTSTATUS dcerpc_ndr_request(struct dcerpc_pipe *p, goto failed; } + DEBUG(10,("rpc reply data:\n")); dump_data(10, pull->data, pull->data_size); /* pull the structure from the blob */ |