summaryrefslogtreecommitdiff
path: root/source4/librpc
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-12-16 09:20:34 +0000
committerAndrew Tridgell <tridge@samba.org>2003-12-16 09:20:34 +0000
commit7779b1e00022599f9b77dab7f5f983d930514f15 (patch)
treeb1e860ce476e5b15993f5532d5c3a854f912e83e /source4/librpc
parent24c22aef90d8534ee2d016b37b2b302f1367d106 (diff)
downloadsamba-7779b1e00022599f9b77dab7f5f983d930514f15.tar.gz
samba-7779b1e00022599f9b77dab7f5f983d930514f15.tar.bz2
samba-7779b1e00022599f9b77dab7f5f983d930514f15.zip
added support for big-endian ucs2 strings (as used by big-endian
msrpc). this was easier than I expected! (This used to be commit a0a51af6b746b1f82faaa49d33c17fea9d708fb0)
Diffstat (limited to 'source4/librpc')
-rw-r--r--source4/librpc/ndr/ndr_basic.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c
index ed75b8c27c..cde0b52f3b 100644
--- a/source4/librpc/ndr/ndr_basic.c
+++ b/source4/librpc/ndr/ndr_basic.c
@@ -344,11 +344,16 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
uint32 len1, ofs, len2;
uint16 len3;
int ret;
+ int chset = CH_UCS2;
if (!(ndr_flags & NDR_SCALARS)) {
return NT_STATUS_OK;
}
+ if (ndr->flags & LIBNDR_FLAG_BIGENDIAN) {
+ chset = CH_UCS2BE;
+ }
+
switch (ndr->flags & LIBNDR_STRING_FLAGS) {
case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4:
case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM:
@@ -365,7 +370,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
break;
}
NDR_PULL_NEED_BYTES(ndr, len2*2);
- ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX,
+ ret = convert_string_talloc(ndr->mem_ctx, chset, CH_UNIX,
ndr->data+ndr->offset,
len2*2,
(const void **)&as);
@@ -384,7 +389,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
*s = talloc_strdup(ndr->mem_ctx, "");
break;
}
- ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX,
+ ret = convert_string_talloc(ndr->mem_ctx, chset, CH_UNIX,
ndr->data+ndr->offset,
len1*2,
(const void **)&as);
@@ -402,7 +407,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
if (len1*2+2 <= ndr->data_size - ndr->offset) {
len1++;
}
- ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX,
+ ret = convert_string_talloc(ndr->mem_ctx, chset, CH_UNIX,
ndr->data+ndr->offset,
len1*2,
(const void **)s);
@@ -461,10 +466,15 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s)
{
ssize_t s_len, c_len;
int ret;
+ int chset = CH_UCS2;
if (!(ndr_flags & NDR_SCALARS)) {
return NT_STATUS_OK;
}
+
+ if (ndr->flags & LIBNDR_FLAG_BIGENDIAN) {
+ chset = CH_UCS2BE;
+ }
s_len = s?strlen(s):0;
c_len = s?strlen_m(s):0;
@@ -475,7 +485,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s)
NDR_CHECK(ndr_push_uint32(ndr, 0));
NDR_CHECK(ndr_push_uint32(ndr, c_len+1));
NDR_PUSH_NEED_BYTES(ndr, c_len*2 + 2);
- ret = convert_string(CH_UNIX, CH_UCS2,
+ ret = convert_string(CH_UNIX, chset,
s, s_len+1,
ndr->data+ndr->offset, c_len*2 + 2);
if (ret == -1) {
@@ -490,7 +500,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s)
NDR_CHECK(ndr_push_uint32(ndr, 0));
NDR_CHECK(ndr_push_uint32(ndr, c_len));
NDR_PUSH_NEED_BYTES(ndr, c_len*2);
- ret = convert_string(CH_UNIX, CH_UCS2,
+ ret = convert_string(CH_UNIX, chset,
s, s_len,
ndr->data+ndr->offset, c_len*2);
if (ret == -1) {
@@ -503,7 +513,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s)
case LIBNDR_FLAG_STR_SIZE4:
NDR_CHECK(ndr_push_uint32(ndr, c_len + 1));
NDR_PUSH_NEED_BYTES(ndr, c_len*2 + 2);
- ret = convert_string(CH_UNIX, CH_UCS2,
+ ret = convert_string(CH_UNIX, chset,
s, s_len + 1,
ndr->data+ndr->offset, c_len*2 + 2);
if (ret == -1) {
@@ -515,7 +525,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s)
case LIBNDR_FLAG_STR_NULLTERM:
NDR_PUSH_NEED_BYTES(ndr, c_len*2 + 2);
- ret = convert_string(CH_UNIX, CH_UCS2,
+ ret = convert_string(CH_UNIX, chset,
s, s_len+1,
ndr->data+ndr->offset, c_len*2 + 2);
if (ret == -1) {