mirror of
https://github.com/samba-team/samba.git
synced 2025-02-25 17:57:42 +03:00
r26438: Store iconv convenience in tdr push contexts.
(This used to be commit dffef3162778aebe2f8d77e2da60b22adb7d60ef)
This commit is contained in:
parent
e8f46760e0
commit
5e00673a40
@ -24,6 +24,7 @@
|
||||
#include "lib/registry/tdr_regf.h"
|
||||
#include "librpc/gen_ndr/ndr_security.h"
|
||||
#include "librpc/gen_ndr/winreg.h"
|
||||
#include "param/param.h"
|
||||
|
||||
static struct hive_operations reg_backend_regf;
|
||||
|
||||
@ -47,6 +48,7 @@ struct regf_data {
|
||||
int fd;
|
||||
struct hbin_block **hbins;
|
||||
struct regf_hdr *header;
|
||||
struct smb_iconv_convenience *iconv_convenience;
|
||||
};
|
||||
|
||||
static WERROR regf_save_hbin(struct regf_data *data);
|
||||
@ -263,7 +265,7 @@ static uint32_t hbin_store (struct regf_data *data, DATA_BLOB blob)
|
||||
static uint32_t hbin_store_tdr(struct regf_data *data,
|
||||
tdr_push_fn_t push_fn, void *p)
|
||||
{
|
||||
struct tdr_push *push = talloc_zero(data, struct tdr_push);
|
||||
struct tdr_push *push = tdr_push_init(data, data->iconv_convenience);
|
||||
uint32_t ret;
|
||||
|
||||
if (NT_STATUS_IS_ERR(push_fn(push, p))) {
|
||||
@ -390,7 +392,7 @@ static uint32_t hbin_store_tdr_resize(struct regf_data *regf,
|
||||
tdr_push_fn_t push_fn,
|
||||
uint32_t orig_offset, void *p)
|
||||
{
|
||||
struct tdr_push *push = talloc_zero(regf, struct tdr_push);
|
||||
struct tdr_push *push = tdr_push_init(regf, regf->iconv_convenience);
|
||||
uint32_t ret;
|
||||
|
||||
if (NT_STATUS_IS_ERR(push_fn(push, p))) {
|
||||
@ -1788,7 +1790,7 @@ static WERROR regf_set_value(struct hive_key *key, const char *name,
|
||||
|
||||
static WERROR regf_save_hbin(struct regf_data *regf)
|
||||
{
|
||||
struct tdr_push *push = talloc_zero(regf, struct tdr_push);
|
||||
struct tdr_push *push = tdr_push_init(regf, regf->iconv_convenience);
|
||||
int i;
|
||||
|
||||
W_ERROR_HAVE_NO_MEMORY(push);
|
||||
@ -1806,7 +1808,7 @@ static WERROR regf_save_hbin(struct regf_data *regf)
|
||||
regf->header->chksum = regf_hdr_checksum(push->data.data);
|
||||
talloc_free(push);
|
||||
|
||||
if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd,
|
||||
if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd, regf->iconv_convenience,
|
||||
(tdr_push_fn_t)tdr_push_regf_hdr,
|
||||
regf->header))) {
|
||||
DEBUG(0, ("Error writing registry file header\n"));
|
||||
@ -1819,7 +1821,7 @@ static WERROR regf_save_hbin(struct regf_data *regf)
|
||||
}
|
||||
|
||||
for (i = 0; regf->hbins[i]; i++) {
|
||||
if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd,
|
||||
if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd, regf->iconv_convenience,
|
||||
(tdr_push_fn_t)tdr_push_hbin_block,
|
||||
regf->hbins[i]))) {
|
||||
DEBUG(0, ("Error writing HBIN block\n"));
|
||||
@ -1842,6 +1844,8 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
|
||||
|
||||
regf = (struct regf_data *)talloc_zero(NULL, struct regf_data);
|
||||
|
||||
regf->iconv_convenience = lp_iconv_convenience(global_loadparm);
|
||||
|
||||
W_ERROR_HAVE_NO_MEMORY(regf);
|
||||
|
||||
DEBUG(5, ("Attempting to create registry file\n"));
|
||||
@ -1927,6 +1931,8 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
|
||||
|
||||
regf = (struct regf_data *)talloc_zero(NULL, struct regf_data);
|
||||
|
||||
regf->iconv_convenience = lp_iconv_convenience(global_loadparm);
|
||||
|
||||
W_ERROR_HAVE_NO_MEMORY(regf);
|
||||
|
||||
DEBUG(5, ("Attempting to load registry file\n"));
|
||||
|
@ -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,10 +372,22 @@ 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;
|
||||
|
||||
|
@ -38,6 +38,7 @@ struct tdr_pull {
|
||||
struct tdr_push {
|
||||
DATA_BLOB data;
|
||||
int flags;
|
||||
struct smb_iconv_convenience *iconv_convenience;
|
||||
};
|
||||
|
||||
struct tdr_print {
|
||||
|
@ -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");
|
||||
|
@ -56,7 +56,7 @@ static NTSTATUS unicode_open(struct torture_context *tctx,
|
||||
}
|
||||
SSVAL(ucs_name, i*2, 0);
|
||||
|
||||
i = convert_string_talloc(ucs_name, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname);
|
||||
i = convert_string_talloc(ucs_name, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname);
|
||||
if (i == -1) {
|
||||
torture_comment(tctx, "Failed to convert UCS2 Name into unix - convert_string_talloc() failure\n");
|
||||
talloc_free(ucs_name);
|
||||
|
@ -50,7 +50,7 @@ bool torture_utable(struct torture_context *tctx,
|
||||
SSVAL(c2, 0, c);
|
||||
fstrcpy(fname, "\\utable\\x");
|
||||
p = fname+strlen(fname);
|
||||
len = convert_string(lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX,
|
||||
len = convert_string(lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX,
|
||||
c2, 2,
|
||||
p, sizeof(fname)-strlen(fname));
|
||||
p[len] = 0;
|
||||
|
@ -183,7 +183,7 @@ static NTSTATUS rap_pull_string(TALLOC_CTX *mem_ctx, struct ndr_pull *ndr,
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
|
||||
*dest = talloc_zero_array(mem_ctx, char, len+1);
|
||||
pull_string(lp_iconv_convenience(global_loadparm), *dest, p, len+1, len, STR_ASCII);
|
||||
pull_string(ndr->iconv_convenience, *dest, p, len+1, len, STR_ASCII);
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ static bool test_EnumPrinterKey(struct torture_context *tctx,
|
||||
|
||||
torture_assert_werr_ok(tctx, epk.out.result, "EnumPrinterKey failed");
|
||||
|
||||
convert_string_talloc(ctx, lp_iconv_convenience(global_loadparm), CH_UTF16,
|
||||
convert_string_talloc(ctx, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16,
|
||||
CH_UNIX, epk.out.key_buffer, epk.out.needed,
|
||||
(void**)&ctx->printer_keys);
|
||||
|
||||
|
@ -966,7 +966,7 @@ static bool test_NetrMessageBufferSend(struct torture_context *tctx,
|
||||
size_t size;
|
||||
uint8_t *msg;
|
||||
|
||||
size = push_ucs2_talloc(tctx, lp_iconv_convenience(global_loadparm),
|
||||
size = push_ucs2_talloc(tctx, lp_iconv_convenience(tctx->lp_ctx),
|
||||
(void **)&msg, message);
|
||||
|
||||
r.in.server_name = dcerpc_server_name(p);
|
||||
|
Loading…
x
Reference in New Issue
Block a user