diff --git a/source/lib/util_str.c b/source/lib/util_str.c index 285b0cc02eb..6005a3e49a0 100644 --- a/source/lib/util_str.c +++ b/source/lib/util_str.c @@ -1091,6 +1091,21 @@ size_t strlen_m(const char *s) return count + strlen_w(tmpbuf); } +/** + Work out the number of multibyte chars in a string, including the NULL + terminator. +**/ +size_t strlen_m_term(const char *s) +{ + size_t count = 0; + + if (!s) { + return 0; + } + + return strlen_m(s) + 1; +} + /** Convert a string to upper case. **/ diff --git a/source/librpc/idl/winreg.idl b/source/librpc/idl/winreg.idl index c7dc3942dfc..263946bdda9 100644 --- a/source/librpc/idl/winreg.idl +++ b/source/librpc/idl/winreg.idl @@ -10,8 +10,8 @@ ] interface winreg { typedef struct { - [value(2*(strlen_m(r->name)+1))] uint16 name_len; - [value(r->name_len)] uint16 name_size; + [value(strlen_m_term(r->name)*2)] uint16 name_len; + [value(r->name_len)] uint16 name_size; unistr *name; } winreg_String;