]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
It looks like the rpc client code in libsmb hasn't been converted to the
authorTim Potter <tpot@samba.org>
Fri, 20 Jul 2001 01:32:56 +0000 (01:32 +0000)
committerTim Potter <tpot@samba.org>
Fri, 20 Jul 2001 01:32:56 +0000 (01:32 +0000)
new internal string stuff.  The main problem is that some unicode strings
are null terminated and some aren't.  There's no rhyme or reason to it -
some pipes have 99% of the strings terminated and some have 99%
unterminated.  To avoid having to actually know the termination policy, I
propose a set of functions that take a UNISTR2* and use the length
contained there.

Added rpcstr_pull_unistr2_string() function to convert a unicode string of
dubious termination to a fstring.

source/lib/util_unistr.c

index 4a1117d8d07fae514731190394c2b6ba5c077752..48bff4c41cce8bde04d142b0eba87e03948de8f9 100644 (file)
@@ -72,6 +72,16 @@ int rpcstr_pull(char* dest, void *src, int dest_len, int src_len, int flags)
        return pull_ucs2(NULL, dest, src, dest_len, src_len, flags|STR_UNICODE|STR_NOALIGN);
 }
 
+/* Copy a string from a unistr2 source to internal samba format
+   destination.  Use this instead of direct calls to rpcstr_pull() to avoid
+   having to determine whether the source string is null terminated. */
+
+int rpcstr_pull_unistr2_fstring(char *dest, UNISTR2 *src)
+{
+        return pull_ucs2(NULL, dest, src->buffer, sizeof(fstring),
+                         src->uni_str_len * 2, 0);
+}
+
 /* Converts a string from internal samba format to unicode
  */ 
 int rpcstr_push(void* dest, const char *src, int dest_len, int flags)