use jeremy's versions of the UNICODE routines.
authorLuke Leighton <lkcl@samba.org>
Wed, 10 Feb 1999 22:30:47 +0000 (22:30 +0000)
committerLuke Leighton <lkcl@samba.org>
Wed, 10 Feb 1999 22:30:47 +0000 (22:30 +0000)
(This used to be commit c5109ff782be8774db47a92b48ca6335ec8d6065)

source3/include/proto.h
source3/lib/util_unistr.c
source3/rpc_server/srv_pipe.c
source3/smbd/chgpasswd.c
source3/utils/torture.c

index 2ed35ee0af34c57b0994fe8be8db7c1c6174b063..f649b40332352d3e44462c82325bd074bd6231c4 100644 (file)
@@ -566,13 +566,13 @@ void split_at_last_component(char *path, char *front, char sep, char *back);
 
 int PutUniCode(char *dst,char *src);
 char *skip_unicode_string(char *buf,int n);
-char *unistrn2(char *buf, int len);
-char *unistr2(uint16 *buf);
+char *unistrn2(uint16 *src, int len);
+char *unistr2(uint16 *src);
 char *unistr2_to_str(UNISTR2 *str);
 uint32 buffer2_to_uint32(BUFFER2 *str);
 char *buffer2_to_str(BUFFER2 *str);
 char *buffer2_to_multistr(BUFFER2 *str);
-int struni2(char *p, const char *buf);
+int struni2(char *dst, const char *src);
 char *unistr(char *buf);
 int unistrcpy(char *dst, char *src);
 
index 50bb73f4fb85a1343c9627d46182d7134aca0192..5e73fe6ada2f8842bd577607619c02194b936dfa 100644 (file)
 
 #include "includes.h"
 
+#ifndef MAXUNI
+#define MAXUNI 1024
+#endif
+
 /*******************************************************************
-write a string in unicoode format
+write a string in (little-endian) unicoode format
 ********************************************************************/
+
 int PutUniCode(char *dst,char *src)
 {
   int ret = 0;
   while (*src) {
-    dst[ret++] = src[0];
-    dst[ret++] = 0;    
+    SSVAL(dst,ret,(*src) & 0xFF);
+    ret += 2;
     src++;
   }
-  dst[ret++]=0;
-  dst[ret++]=0;
+  SSVAL(dst,ret,0);
+  ret += 2;
   return(ret);
 }
 
 /*******************************************************************
 skip past some unicode strings in a buffer
 ********************************************************************/
+
 char *skip_unicode_string(char *buf,int n)
 {
   while (n--)
@@ -52,11 +58,11 @@ char *skip_unicode_string(char *buf,int n)
 }
 
 /*******************************************************************
-Return a ascii version of a unicode string
+Return a ascii version of a little-endian unicode string.
 Hack alert: uses fixed buffer(s) and only handles ascii strings
 ********************************************************************/
-#define MAXUNI 1024
-char *unistrn2(char *buf, int len)
+
+char *unistrn2(uint16 *src, int len)
 {
        static char lbufs[8][MAXUNI];
        static int nexti;
@@ -65,9 +71,9 @@ char *unistrn2(char *buf, int len)
 
        nexti = (nexti+1)%8;
 
-       for (p = lbuf; *buf && p-lbuf < MAXUNI-2 && len > 0; len--, p++, buf+=2)
+       for (p = lbuf; *src && p-lbuf < MAXUNI-2 && len > 0; len--, src++)
        {
-               SSVAL(p, 0, *buf);
+               *p++ = (*src & 0xff);
        }
 
        *p = 0;
@@ -76,21 +82,22 @@ char *unistrn2(char *buf, int len)
 
 static char lbufs[8][MAXUNI];
 static int nexti;
+
 /*******************************************************************
-Return a ascii version of a unicode string
+Return a ascii version of a little-endian unicode string.
 Hack alert: uses fixed buffer(s) and only handles ascii strings
 ********************************************************************/
-#define MAXUNI 1024
-char *unistr2(uint16 *buf)
+
+char *unistr2(uint16 *src)
 {
        char *lbuf = lbufs[nexti];
        char *p;
 
        nexti = (nexti+1)%8;
 
-       for (p = lbuf; *buf && p-lbuf < MAXUNI-2; p++, buf++)
+       for (p = lbuf; *src && p-lbuf < MAXUNI-2; p++, src++)
        {
-               *p = *buf;
+               *p = (*src & 0xff);
        }
 
        *p = 0;
@@ -98,20 +105,21 @@ char *unistr2(uint16 *buf)
 }
 
 /*******************************************************************
-Return a ascii version of a unicode string
+Return a ascii version of a little-endian unicode string
 ********************************************************************/
+
 char *unistr2_to_str(UNISTR2 *str)
 {
        char *lbuf = lbufs[nexti];
        char *p;
-       uint16 *buf = str->buffer;
+       uint16 *src = str->buffer;
        int max_size = MIN(sizeof(str->buffer)-2, str->uni_str_len);
 
        nexti = (nexti+1)%8;
 
-       for (p = lbuf; *buf && p-lbuf < max_size; p++, buf++)
+       for (p = lbuf; *src && p-lbuf < max_size; p++, src++)
        {
-               *p = *buf;
+               *p = (*src & 0xff);
        }
 
        *p = 0;
@@ -121,6 +129,7 @@ char *unistr2_to_str(UNISTR2 *str)
 /*******************************************************************
 Return a number stored in a buffer
 ********************************************************************/
+
 uint32 buffer2_to_uint32(BUFFER2 *str)
 {
        if (str->buf_len == 4)
@@ -136,18 +145,19 @@ uint32 buffer2_to_uint32(BUFFER2 *str)
 /*******************************************************************
 Return a ascii version of a NOTunicode string
 ********************************************************************/
+
 char *buffer2_to_str(BUFFER2 *str)
 {
        char *lbuf = lbufs[nexti];
        char *p;
-       uint16 *buf = str->buffer;
+       uint16 *src = str->buffer;
        int max_size = MIN(sizeof(str->buffer)-2, str->buf_len/2);
 
        nexti = (nexti+1)%8;
 
-       for (p = lbuf; *buf && p-lbuf < max_size; p++, buf++)
+       for (p = lbuf; *src && p-lbuf < max_size; p++, src++)
        {
-               *p = *buf;
+               *p = (*src & 0xff);
        }
 
        *p = 0;
@@ -157,24 +167,25 @@ char *buffer2_to_str(BUFFER2 *str)
 /*******************************************************************
 Return a ascii version of a NOTunicode string
 ********************************************************************/
+
 char *buffer2_to_multistr(BUFFER2 *str)
 {
        char *lbuf = lbufs[nexti];
        char *p;
-       uint16 *buf = str->buffer;
+       uint16 *src = str->buffer;
        int max_size = MIN(sizeof(str->buffer)-2, str->buf_len/2);
 
        nexti = (nexti+1)%8;
 
-       for (p = lbuf; p-lbuf < max_size; p++, buf++)
+       for (p = lbuf; p-lbuf < max_size; p++, src++)
        {
-               if (*buf == 0)
+               if (*src == 0)
                {
                        *p = ' ';
                }
                else
                {
-                       *p = *buf;
+                       *p = (*src & 0xff);
                }
        }
 
@@ -185,34 +196,35 @@ char *buffer2_to_multistr(BUFFER2 *str)
 /*******************************************************************
 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
+Unicode strings created are in little-endian format.
 ********************************************************************/
-#define MAXUNI 1024
-int struni2(char *p, const char *buf)
+
+int struni2(char *dst, const char *src)
 {
-       int len = 0;
+       size_t len = 0;
 
-       if (p == NULL) return 0;
+       if (dst == NULL)
+               return 0;
 
-       if (buf != NULL)
+       if (src != NULL)
        {
-               for (; *buf && len < MAXUNI-2; len++, p += 2, buf++)
+               for (; *src && len < MAXUNI-2; len++, dst +=2, src++)
                {
-                       SSVAL(p, 0, *buf);
+                       SSVAL(dst,0,(*src) & 0xFF);
                }
        }
 
-       *p = 0;
+       SSVAL(dst,0,0);
 
        return len;
 }
 
 /*******************************************************************
-Return a ascii version of a unicode string
+Return a ascii version of a little-endian unicode string.
 Hack alert: uses fixed buffer(s) and only handles ascii strings
 ********************************************************************/
-#define MAXUNI 1024
+
 char *unistr(char *buf)
 {
        char *lbuf = lbufs[nexti];
@@ -232,6 +244,7 @@ char *unistr(char *buf)
 /*******************************************************************
 strcpy for unicode strings.  returns length (in num of wide chars)
 ********************************************************************/
+
 int unistrcpy(char *dst, char *src)
 {
        int num_wchars = 0;
@@ -247,4 +260,3 @@ int unistrcpy(char *dst, char *src)
 
        return num_wchars;
 }
-
index 5908fe06b5258bb74d3792e117c958f8dccc35d9..f8d882cd0c85a6717b7c4e9f5a32e78878eb7913 100644 (file)
@@ -225,9 +225,9 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p)
 
        if (IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_UNICODE))
        {
-               fstrcpy(p->user_name, unistrn2(p->ntlmssp_resp.user  , p->ntlmssp_resp.hdr_usr   .str_str_len/2));
-               fstrcpy(p->domain   , unistrn2(p->ntlmssp_resp.domain, p->ntlmssp_resp.hdr_domain.str_str_len/2));
-               fstrcpy(p->wks      , unistrn2(p->ntlmssp_resp.wks   , p->ntlmssp_resp.hdr_wks   .str_str_len/2));
+               fstrcpy(p->user_name, unistrn2((uint16*)p->ntlmssp_resp.user  , p->ntlmssp_resp.hdr_usr   .str_str_len/2));
+               fstrcpy(p->domain   , unistrn2((uint16*)p->ntlmssp_resp.domain, p->ntlmssp_resp.hdr_domain.str_str_len/2));
+               fstrcpy(p->wks      , unistrn2((uint16*)p->ntlmssp_resp.wks   , p->ntlmssp_resp.hdr_wks   .str_str_len/2));
        }
        else
        {
index a2e75ecc431e7e37908411aba8fa35f060e5deed..9791d3a38ee8f9a4c9dd16023413128db67e109e 100644 (file)
@@ -693,7 +693,7 @@ BOOL check_oem_password(char *user,
                int uni_pw_len = new_pw_len;
                char *pw;
                new_pw_len /= 2;
-               pw = unistrn2(&lmdata[512-uni_pw_len], new_pw_len);
+               pw = unistrn2((uint16*)(&lmdata[512-uni_pw_len]), new_pw_len);
                memcpy(new_passwd, pw, new_pw_len+1);
        }
        else
index fb09f515cf58022166de2e3a626c3be21b9355b0..be77c48cfee6c7e77948956744178b67180af61a 100644 (file)
@@ -1167,9 +1167,9 @@ static void create_procs(int nprocs, int numops, void (*fn)(int ))
        printf("host=%s share=%s user=%s myname=%s procs=%d ops=%d\n", 
               host, share, username, myname, nprocs, numops);
 
-       create_procs(nprocs, numops, run_connection);
-/*
        create_procs(nprocs, numops, run_randomipc);
+/*
+       create_procs(nprocs, numops, run_connection);
 
        run_fdpasstest();
        run_locktest1();