From 11a3d78951c897c46264203daaad12a3ead5cf8c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 25 Aug 2010 10:05:15 +0200 Subject: [PATCH] librpc/ndr: correctly implement ndr_charset_length() Before we ignored the charset type. metze --- librpc/ndr/ndr_string.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/librpc/ndr/ndr_string.c b/librpc/ndr/ndr_string.c index 568c36845e5..2e04633963b 100644 --- a/librpc/ndr/ndr_string.c +++ b/librpc/ndr/ndr_string.c @@ -714,7 +714,19 @@ _PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags, /* Return number of elements in a string in the specified charset */ _PUBLIC_ uint32_t ndr_charset_length(const void *var, charset_t chset) { - /* FIXME: Treat special chars special here, taking chset into account */ - /* Also include 0 byte */ + switch (chset) { + /* case CH_UTF16: this has the same value as CH_UTF16LE */ + case CH_UTF16LE: + case CH_UTF16BE: + case CH_UTF16MUNGED: + return strlen_m_term((const char *)var); + case CH_DISPLAY: + case CH_DOS: + case CH_UNIX: + case CH_UTF8: + return strlen((const char *)var)+1; + } + + /* Fallback, this should never happen */ return strlen((const char *)var)+1; } -- 2.11.4.GIT