From 520878fd1f440a7313cedb4827bdc81454d94d20 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 29 Oct 1997 19:05:34 +0000 Subject: ipc.c ntclientpipe.c: response to Bind Acknowledgment needs a lookup table for the PIPE string (secondary address in RPC_HDR_BA structure). smbparse.c util.c : interesting problem, i think caused by us typecasting a uint16* buffer to char*. found on a SPARC. (This used to be commit 420408ee83902faa6cf871f26e93ad5efb483727) --- source3/lib/util.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index 7f47cdbdb4..4d098013f2 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -4284,11 +4284,19 @@ char *unistrn2(uint16 *buf, int len) static int nexti; char *lbuf = lbufs[nexti]; char *p; + nexti = (nexti+1)%8; + + DEBUG(10, ("unistrn2: ")); + for (p = lbuf; *buf && p-lbuf < MAXUNI-2 && len > 0; len--, p++, buf++) { + DEBUG(10, ("%4x ", *buf)); *p = *buf; } + + DEBUG(10,("\n")); + *p = 0; return lbuf; } @@ -4304,15 +4312,54 @@ char *unistr2(uint16 *buf) static int nexti; char *lbuf = lbufs[nexti]; char *p; + nexti = (nexti+1)%8; + + DEBUG(10, ("unistr2: ")); + for (p = lbuf; *buf && p-lbuf < MAXUNI-2; p++, buf++) { + DEBUG(10, ("%4x ", *buf)); *p = *buf; } + + DEBUG(10,("\n")); + *p = 0; return lbuf; } +/******************************************************************* +create a null-terminated unicode string from a null-terminated ascii string. +return number of unicode chars copied, excluding the null character. + +only handles ascii strings +********************************************************************/ +#define MAXUNI 1024 +int struni2(uint16 *p, char *buf) +{ + int len = 0; + + if (p == NULL) return 0; + + DEBUG(10, ("struni2: ")); + + if (buf != NULL) + { + for (; *buf && len < MAXUNI-2; len++, p++, buf++) + { + DEBUG(10, ("%2x ", *buf)); + *p = *buf; + } + + DEBUG(10,("\n")); + } + + *p = 0; + + return len; +} + /******************************************************************* Return a ascii version of a unicode string Hack alert: uses fixed buffer(s) and only handles ascii strings -- cgit