summaryrefslogtreecommitdiff
path: root/source4/lib/tdr
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/tdr')
-rw-r--r--source4/lib/tdr/tdr.c16
-rw-r--r--source4/lib/tdr/tdr.h1
-rw-r--r--source4/lib/tdr/testsuite.c9
3 files changed, 20 insertions, 6 deletions
diff --git a/source4/lib/tdr/tdr.c b/source4/lib/tdr/tdr.c
index 80e1d9ae24..1a52f10569 100644
--- a/source4/lib/tdr/tdr.c
+++ b/source4/lib/tdr/tdr.c
@@ -176,7 +176,7 @@ NTSTATUS tdr_push_charset(struct tdr_push *tdr, const char **v, uint32_t length,
required = el_size * length;
TDR_PUSH_NEED_BYTES(tdr, required);
- ret = convert_string(lp_iconv_convenience(global_loadparm), CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required);
+ ret = convert_string(tdr->iconv_convenience, CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required);
if (ret == -1) {
return NT_STATUS_INVALID_PARAMETER;
@@ -372,11 +372,23 @@ NTSTATUS tdr_pull_DATA_BLOB(struct tdr_pull *tdr, TALLOC_CTX *ctx, DATA_BLOB *bl
return NT_STATUS_OK;
}
-NTSTATUS tdr_push_to_fd(int fd, tdr_push_fn_t push_fn, const void *p)
+struct tdr_push *tdr_push_init(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *ic)
{
struct tdr_push *push = talloc_zero(NULL, struct tdr_push);
if (push == NULL)
+ return NULL;
+
+ push->iconv_convenience = talloc_reference(push, ic);
+
+ return push;
+}
+
+NTSTATUS tdr_push_to_fd(int fd, struct smb_iconv_convenience *iconv_convenience, tdr_push_fn_t push_fn, const void *p)
+{
+ struct tdr_push *push = tdr_push_init(NULL, iconv_convenience);
+
+ if (push == NULL)
return NT_STATUS_NO_MEMORY;
if (NT_STATUS_IS_ERR(push_fn(push, p))) {
diff --git a/source4/lib/tdr/tdr.h b/source4/lib/tdr/tdr.h
index 689b9f3ebb..84e04a5327 100644
--- a/source4/lib/tdr/tdr.h
+++ b/source4/lib/tdr/tdr.h
@@ -38,6 +38,7 @@ struct tdr_pull {
struct tdr_push {
DATA_BLOB data;
int flags;
+ struct smb_iconv_convenience *iconv_convenience;
};
struct tdr_print {
diff --git a/source4/lib/tdr/testsuite.c b/source4/lib/tdr/testsuite.c
index 20afca25a5..c3c85b5ab6 100644
--- a/source4/lib/tdr/testsuite.c
+++ b/source4/lib/tdr/testsuite.c
@@ -21,11 +21,12 @@
#include "includes.h"
#include "torture/torture.h"
#include "lib/tdr/tdr.h"
+#include "param/param.h"
static bool test_push_uint8(struct torture_context *tctx)
{
uint8_t v = 4;
- struct tdr_push *tdr = talloc_zero(tctx, struct tdr_push);
+ struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
torture_assert_ntstatus_ok(tctx, tdr_push_uint8(tdr, &v), "push failed");
torture_assert_int_equal(tctx, tdr->data.length, 1, "length incorrect");
@@ -52,7 +53,7 @@ static bool test_pull_uint8(struct torture_context *tctx)
static bool test_push_uint16(struct torture_context *tctx)
{
uint16_t v = 0xF32;
- struct tdr_push *tdr = talloc_zero(tctx, struct tdr_push);
+ struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
torture_assert_ntstatus_ok(tctx, tdr_push_uint16(tdr, &v), "push failed");
torture_assert_int_equal(tctx, tdr->data.length, 2, "length incorrect");
@@ -81,7 +82,7 @@ static bool test_pull_uint16(struct torture_context *tctx)
static bool test_push_uint32(struct torture_context *tctx)
{
uint32_t v = 0x100F32;
- struct tdr_push *tdr = talloc_zero(tctx, struct tdr_push);
+ struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
torture_assert_ntstatus_ok(tctx, tdr_push_uint32(tdr, &v), "push failed");
torture_assert_int_equal(tctx, tdr->data.length, 4, "length incorrect");
@@ -151,7 +152,7 @@ static bool test_pull_charset_empty(struct torture_context *tctx)
static bool test_push_charset(struct torture_context *tctx)
{
const char *l = "bloe";
- struct tdr_push *tdr = talloc_zero(tctx, struct tdr_push);
+ struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
torture_assert_ntstatus_ok(tctx, tdr_push_charset(tdr, &l, 4, 1, CH_UTF8),
"push failed");
torture_assert_int_equal(tctx, 4, tdr->data.length, "offset invalid");