summaryrefslogtreecommitdiff
path: root/source4/librpc/ndr
diff options
context:
space:
mode:
Diffstat (limited to 'source4/librpc/ndr')
-rw-r--r--source4/librpc/ndr/libndr.h4
-rw-r--r--source4/librpc/ndr/ndr.c26
-rw-r--r--source4/librpc/ndr/ndr_compression.c6
-rw-r--r--source4/librpc/ndr/ndr_spoolss_buf.c13
-rw-r--r--source4/librpc/ndr/ndr_string.c23
5 files changed, 41 insertions, 31 deletions
diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h
index 2ac0b86f57..1ecc6f3c38 100644
--- a/source4/librpc/ndr/libndr.h
+++ b/source4/librpc/ndr/libndr.h
@@ -52,6 +52,8 @@ struct ndr_pull {
uint32_t data_size;
uint32_t offset;
+ struct smb_iconv_convenience *iconv_convenience;
+
uint32_t relative_base_offset;
struct ndr_token_list *relative_base_list;
@@ -84,6 +86,8 @@ struct ndr_push {
/* this is used to ensure we generate unique reference IDs */
uint32_t ptr_count;
+
+ struct smb_iconv_convenience *iconv_convenience;
};
/* structure passed to functions that print IDL structures */
diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c
index 40afeacebf..0dafda7086 100644
--- a/source4/librpc/ndr/ndr.c
+++ b/source4/librpc/ndr/ndr.c
@@ -30,6 +30,7 @@
#include "librpc/ndr/libndr.h"
#include "lib/util/dlinklist.h"
#include "librpc/gen_ndr/dcerpc.h"
+#include "param/param.h"
#define NDR_BASE_MARSHALL_SIZE 1024
@@ -56,7 +57,7 @@ _PUBLIC_ size_t ndr_align_size(uint32_t offset, size_t n)
/*
initialise a ndr parse structure from a data blob
*/
-_PUBLIC_ struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx)
+_PUBLIC_ struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience)
{
struct ndr_pull *ndr;
@@ -66,6 +67,7 @@ _PUBLIC_ struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *
ndr->data = blob->data;
ndr->data_size = blob->length;
+ ndr->iconv_convenience = talloc_reference(ndr, iconv_convenience);
return ndr;
}
@@ -99,7 +101,7 @@ static enum ndr_err_code ndr_pull_set_offset(struct ndr_pull *ndr, uint32_t ofs)
}
/* create a ndr_push structure, ready for some marshalling */
-_PUBLIC_ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx)
+_PUBLIC_ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience)
{
struct ndr_push *ndr;
@@ -114,6 +116,7 @@ _PUBLIC_ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx)
if (!ndr->data) {
return NULL;
}
+ ndr->iconv_convenience = talloc_reference(ndr, iconv_convenience);
return ndr;
}
@@ -438,6 +441,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_subcontext_start(struct ndr_pull *ndr,
subndr->data = ndr->data + ndr->offset;
subndr->offset = 0;
subndr->data_size = r_content_size;
+ subndr->iconv_convenience = talloc_reference(subndr, ndr->iconv_convenience);
*_subndr = subndr;
return NDR_ERR_SUCCESS;
@@ -467,7 +471,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_subcontext_start(struct ndr_push *ndr,
{
struct ndr_push *subndr;
- subndr = ndr_push_init_ctx(ndr);
+ subndr = ndr_push_init_ctx(ndr, ndr->iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(subndr);
subndr->flags = ndr->flags;
@@ -690,7 +694,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CT
ndr_pull_flags_fn_t fn)
{
struct ndr_pull *ndr;
- ndr = ndr_pull_init_blob(blob, mem_ctx);
+ ndr = ndr_pull_init_blob(blob, mem_ctx, lp_iconv_convenience(global_loadparm));
NDR_ERR_HAVE_NO_MEMORY(ndr);
NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
return NDR_ERR_SUCCESS;
@@ -703,7 +707,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLO
ndr_pull_flags_fn_t fn)
{
struct ndr_pull *ndr;
- ndr = ndr_pull_init_blob(blob, mem_ctx);
+ ndr = ndr_pull_init_blob(blob, mem_ctx, lp_iconv_convenience(global_loadparm));
NDR_ERR_HAVE_NO_MEMORY(ndr);
NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
if (ndr->offset < ndr->data_size) {
@@ -721,7 +725,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX
uint32_t level, ndr_pull_flags_fn_t fn)
{
struct ndr_pull *ndr;
- ndr = ndr_pull_init_blob(blob, mem_ctx);
+ ndr = ndr_pull_init_blob(blob, mem_ctx, lp_iconv_convenience(global_loadparm));
NDR_ERR_HAVE_NO_MEMORY(ndr);
NDR_CHECK(ndr_pull_set_switch_value(ndr, p, level));
NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
@@ -736,7 +740,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC
uint32_t level, ndr_pull_flags_fn_t fn)
{
struct ndr_pull *ndr;
- ndr = ndr_pull_init_blob(blob, mem_ctx);
+ ndr = ndr_pull_init_blob(blob, mem_ctx, lp_iconv_convenience(global_loadparm));
NDR_ERR_HAVE_NO_MEMORY(ndr);
NDR_CHECK(ndr_pull_set_switch_value(ndr, p, level));
NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
@@ -755,7 +759,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem
ndr_push_flags_fn_t fn)
{
struct ndr_push *ndr;
- ndr = ndr_push_init_ctx(mem_ctx);
+ ndr = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(global_loadparm));
NDR_ERR_HAVE_NO_MEMORY(ndr);
NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
@@ -774,7 +778,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_
uint32_t level, ndr_push_flags_fn_t fn)
{
struct ndr_push *ndr;
- ndr = ndr_push_init_ctx(mem_ctx);
+ ndr = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(global_loadparm));
NDR_ERR_HAVE_NO_MEMORY(ndr);
NDR_CHECK(ndr_push_set_switch_value(ndr, p, level));
@@ -799,7 +803,7 @@ _PUBLIC_ size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t pu
/* avoid recursion */
if (flags & LIBNDR_FLAG_NO_NDR_SIZE) return 0;
- ndr = ndr_push_init_ctx(NULL);
+ ndr = ndr_push_init_ctx(NULL, lp_iconv_convenience(global_loadparm));
if (!ndr) return 0;
ndr->flags |= flags | LIBNDR_FLAG_NO_NDR_SIZE;
status = push(ndr, NDR_SCALARS|NDR_BUFFERS, discard_const(p));
@@ -824,7 +828,7 @@ _PUBLIC_ size_t ndr_size_union(const void *p, int flags, uint32_t level, ndr_pus
/* avoid recursion */
if (flags & LIBNDR_FLAG_NO_NDR_SIZE) return 0;
- ndr = ndr_push_init_ctx(NULL);
+ ndr = ndr_push_init_ctx(NULL, lp_iconv_convenience(global_loadparm));
if (!ndr) return 0;
ndr->flags |= flags | LIBNDR_FLAG_NO_NDR_SIZE;
diff --git a/source4/librpc/ndr/ndr_compression.c b/source4/librpc/ndr/ndr_compression.c
index 411d4a17e2..310f8c4ce4 100644
--- a/source4/librpc/ndr/ndr_compression.c
+++ b/source4/librpc/ndr/ndr_compression.c
@@ -86,7 +86,7 @@ static enum ndr_err_code ndr_pull_compression_mszip(struct ndr_pull *subndr,
struct decomp_state *decomp_state;
bool last = false;
- ndrpush = ndr_push_init_ctx(subndr);
+ ndrpush = ndr_push_init_ctx(subndr, subndr->iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(ndrpush);
decomp_state = ZIPdecomp_state(subndr);
@@ -197,7 +197,7 @@ static enum ndr_err_code ndr_pull_compression_xpress(struct ndr_pull *subndr,
DATA_BLOB uncompressed;
bool last = false;
- ndrpush = ndr_push_init_ctx(subndr);
+ ndrpush = ndr_push_init_ctx(subndr, subndr->iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(ndrpush);
while (!last) {
@@ -264,7 +264,7 @@ enum ndr_err_code ndr_push_compression_start(struct ndr_push *subndr,
{
struct ndr_push *comndr;
- comndr = ndr_push_init_ctx(subndr);
+ comndr = ndr_push_init_ctx(subndr, subndr->iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(comndr);
comndr->flags = subndr->flags;
diff --git a/source4/librpc/ndr/ndr_spoolss_buf.c b/source4/librpc/ndr/ndr_spoolss_buf.c
index 9800430203..e01c5fd225 100644
--- a/source4/librpc/ndr/ndr_spoolss_buf.c
+++ b/source4/librpc/ndr/ndr_spoolss_buf.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "librpc/gen_ndr/ndr_spoolss.h"
+#include "param/param.h"
#define NDR_SPOOLSS_PUSH_ENUM_IN(fn) do { \
if (!r->in.buffer && r->in.offered != 0) {\
@@ -55,7 +56,7 @@
}\
if (r->in.buffer) {\
DATA_BLOB _data_blob_info;\
- _ndr_info = ndr_push_init_ctx(ndr);\
+ _ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience);\
NDR_ERR_HAVE_NO_MEMORY(_ndr_info);\
_ndr_info->flags= ndr->flags;\
if (r->out.info) {\
@@ -120,7 +121,7 @@
r->out.count = _r.out.count;\
r->out.result = _r.out.result;\
if (_r.out.info) {\
- struct ndr_pull *_ndr_info = ndr_pull_init_blob(_r.out.info, ndr);\
+ struct ndr_pull *_ndr_info = ndr_pull_init_blob(_r.out.info, ndr, ndr->iconv_convenience);\
NDR_ERR_HAVE_NO_MEMORY(_ndr_info);\
_ndr_info->flags= ndr->flags;\
if (r->in.offered != _ndr_info->data_size) {\
@@ -164,7 +165,7 @@
#define NDR_SPOOLSS_SIZE_ENUM(fn) do { \
struct __##fn __r;\
DATA_BLOB _data_blob_info;\
- struct ndr_push *_ndr_info = ndr_push_init_ctx(mem_ctx);\
+ struct ndr_push *_ndr_info = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(global_loadparm));\
if (!_ndr_info) return 0;\
_ndr_info->flags|=0;\
__r.in.level = level;\
@@ -414,7 +415,7 @@ enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flag
_r.out.result = r->out.result;
{
struct __spoolss_GetPrinterData __r;
- _ndr_info = ndr_push_init_ctx(ndr);
+ _ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(_ndr_info);
_ndr_info->flags= ndr->flags;
__r.in.type = r->out.type;
@@ -469,7 +470,7 @@ enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flag
}
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);
+ struct ndr_pull *_ndr_data = ndr_pull_init_blob(&_r.out.data, ndr, ndr->iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(_ndr_data);
_ndr_data->flags= ndr->flags;
__r.in.type = r->out.type;
@@ -494,7 +495,7 @@ enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flag
struct __spoolss_SetPrinterData __r;
DATA_BLOB _data_blob_data;
- _ndr_data = ndr_push_init_ctx(ndr);
+ _ndr_data = ndr_push_init_ctx(ndr, ndr->iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(_ndr_data);
_ndr_data->flags= ndr->flags;
diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c
index 7e84211e87..69a7eca1a8 100644
--- a/source4/librpc/ndr/ndr_string.c
+++ b/source4/librpc/ndr/ndr_string.c
@@ -82,7 +82,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
ret = convert_string_talloc(ndr->current_mem_ctx,
- global_smb_iconv_convenience, chset, CH_UNIX,
+ ndr->iconv_convenience, chset, CH_UNIX,
ndr->data+ndr->offset,
(len2 + c_len_term)*byte_mul,
(void **)&as);
@@ -119,7 +119,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
ret = convert_string_talloc(ndr->current_mem_ctx,
- global_smb_iconv_convenience,
+ ndr->iconv_convenience,
chset, CH_UNIX,
ndr->data+ndr->offset,
(len1 + c_len_term)*byte_mul,
@@ -158,7 +158,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
ret = convert_string_talloc(ndr->current_mem_ctx,
- global_smb_iconv_convenience,
+ ndr->iconv_convenience,
chset, CH_UNIX,
ndr->data+ndr->offset,
(len1 + c_len_term)*byte_mul,
@@ -193,7 +193,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
ret = convert_string_talloc(ndr->current_mem_ctx,
- global_smb_iconv_convenience,
+ ndr->iconv_convenience,
chset, CH_UNIX,
ndr->data+ndr->offset,
(len3 + c_len_term)*byte_mul,
@@ -226,7 +226,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
ret = convert_string_talloc(ndr->current_mem_ctx,
- global_smb_iconv_convenience,
+ ndr->iconv_convenience,
chset, CH_UNIX,
ndr->data+ndr->offset,
len3,
@@ -247,7 +247,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset);
}
ret = convert_string_talloc(ndr->current_mem_ctx,
- global_smb_iconv_convenience, chset, CH_UNIX,
+ ndr->iconv_convenience, chset, CH_UNIX,
ndr->data+ndr->offset,
len1,
(void **)&as);
@@ -264,7 +264,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
len1 = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15;
NDR_PULL_NEED_BYTES(ndr, len1*byte_mul);
ret = convert_string_talloc(ndr->current_mem_ctx,
- global_smb_iconv_convenience,
+ ndr->iconv_convenience,
chset, CH_UNIX,
ndr->data+ndr->offset,
len1*byte_mul,
@@ -290,7 +290,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
ret = convert_string_talloc(ndr->current_mem_ctx,
- global_smb_iconv_convenience,
+ ndr->iconv_convenience,
chset, CH_UNIX,
ndr->data+ndr->offset,
len1,
@@ -355,7 +355,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags,
LIBNDR_FLAG_STR_FIXLEN32))) {
s_len++;
}
- d_len = convert_string_talloc(ndr, global_smb_iconv_convenience, CH_UNIX, chset, s, s_len, (void **)&dest);
+ d_len = convert_string_talloc(ndr, ndr->iconv_convenience, CH_UNIX, chset, s, s_len, (void **)&dest);
if (d_len == -1) {
return ndr_push_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
@@ -689,7 +689,8 @@ _PUBLIC_ enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags,
NDR_PULL_NEED_BYTES(ndr, length*byte_mul);
- ret = convert_string_talloc(ndr->current_mem_ctx, global_smb_iconv_convenience,
+ ret = convert_string_talloc(ndr->current_mem_ctx,
+ ndr->iconv_convenience,
chset, CH_UNIX,
ndr->data+ndr->offset,
length*byte_mul,
@@ -714,7 +715,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags,
required = byte_mul * length;
NDR_PUSH_NEED_BYTES(ndr, required);
- ret = convert_string(global_smb_iconv_convenience, CH_UNIX, chset,
+ ret = convert_string(ndr->iconv_convenience, CH_UNIX, chset,
var, strlen(var),
ndr->data+ndr->offset, required);
if (ret == -1) {