diff options
Diffstat (limited to 'source4/librpc')
-rw-r--r-- | source4/librpc/ndr/ndr_basic.c | 24 |
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) { |