summaryrefslogtreecommitdiff
path: root/source4/librpc
diff options
context:
space:
mode:
Diffstat (limited to 'source4/librpc')
-rw-r--r--source4/librpc/idl/echo.idl4
-rw-r--r--source4/librpc/ndr/ndr_string.c38
2 files changed, 39 insertions, 3 deletions
diff --git a/source4/librpc/idl/echo.idl b/source4/librpc/idl/echo.idl
index d841a0974a..a6f52d9d15 100644
--- a/source4/librpc/idl/echo.idl
+++ b/source4/librpc/idl/echo.idl
@@ -34,8 +34,8 @@ interface rpcecho
/* test strings */
void echo_TestCall (
- [in] unistr *s1,
- [out] unistr *s2
+ [in,string,charset(CH_UTF16)] uint16 *s1,
+ [out,string,charset(CH_UTF16)] uint16 *s2
);
diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c
index af9783ed95..95e9df39f0 100644
--- a/source4/librpc/ndr/ndr_string.c
+++ b/source4/librpc/ndr/ndr_string.c
@@ -587,8 +587,10 @@ NTSTATUS ndr_check_string_terminator(struct ndr_pull *ndr, const void *_var, uin
const char *var = _var;
uint32_t i;
+ var += element_size*(count-1);
+
for (i = 0; i < element_size; i++) {
- if (var+element_size*(count-1)+i != 0) {
+ if (var[i] != 0) {
return NT_STATUS_UNSUCCESSFUL;
}
}
@@ -596,3 +598,37 @@ NTSTATUS ndr_check_string_terminator(struct ndr_pull *ndr, const void *_var, uin
return NT_STATUS_OK;
}
+
+NTSTATUS ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, char **var, uint32_t length, uint8_t byte_mul, int chset)
+{
+ int ret;
+ NDR_PULL_NEED_BYTES(ndr, length*byte_mul);
+ ret = convert_string_talloc(ndr, chset, CH_UNIX,
+ ndr->data+ndr->offset,
+ length*byte_mul,
+ (void **)var);
+ if (ret == -1) {
+ return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
+ "Bad character conversion");
+ }
+ NDR_CHECK(ndr_pull_advance(ndr, length*byte_mul));
+
+ return NT_STATUS_OK;
+}
+
+NTSTATUS ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const char *var, uint32_t length, uint8_t byte_mul, int chset)
+{
+ int ret;
+ NDR_PUSH_NEED_BYTES(ndr, byte_mul*length);
+ ret = convert_string(CH_UNIX, chset,
+ var, length,
+ ndr->data+ndr->offset,
+ byte_mul*length);
+ if (ret == -1) {
+ return ndr_push_error(ndr, NDR_ERR_CHARCNV,
+ "Bad character conversion");
+ }
+ ndr->offset += byte_mul*length;
+
+ return NT_STATUS_OK;
+}