UNICODE byte ordering issue: typecast to uint16* replaced with SSVAL()
authorLuke Leighton <lkcl@samba.org>
Mon, 8 Feb 1999 23:40:49 +0000 (23:40 +0000)
committerLuke Leighton <lkcl@samba.org>
Mon, 8 Feb 1999 23:40:49 +0000 (23:40 +0000)
source/include/proto.h
source/lib/util_unistr.c
source/libsmb/smbencrypt.c
source/rpc_parse/parse_misc.c
source/rpc_parse/parse_reg.c
source/rpc_parse/parse_rpc.c
source/rpc_server/srv_pipe.c
source/smbd/chgpasswd.c

index 301fcbe755e43c354c1f7fe5fdfb18a49401f21e..8f2d73f95fab6b585a07b2cafb9a3fc02a993372 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(uint16 *buf, int len);
+char *unistrn2(char *buf, int len);
 char *unistr2(uint16 *buf);
 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(uint16 *p, const char *buf);
+int struni2(char *p, const char *buf);
 char *unistr(char *buf);
 int unistrcpy(char *dst, char *src);
 
index c58820cfeced603c8000191128ff94ad945e89b6..50bb73f4fb85a1343c9627d46182d7134aca0192 100644 (file)
@@ -56,7 +56,7 @@ Return a ascii version of a unicode string
 Hack alert: uses fixed buffer(s) and only handles ascii strings
 ********************************************************************/
 #define MAXUNI 1024
-char *unistrn2(uint16 *buf, int len)
+char *unistrn2(char *buf, int len)
 {
        static char lbufs[8][MAXUNI];
        static int nexti;
@@ -65,9 +65,9 @@ char *unistrn2(uint16 *buf, int len)
 
        nexti = (nexti+1)%8;
 
-       for (p = lbuf; *buf && p-lbuf < MAXUNI-2 && len > 0; len--, p++, buf++)
+       for (p = lbuf; *buf && p-lbuf < MAXUNI-2 && len > 0; len--, p++, buf+=2)
        {
-               *p = *buf;
+               SSVAL(p, 0, *buf);
        }
 
        *p = 0;
@@ -189,7 +189,7 @@ return number of unicode chars copied, excluding the null character.
 only handles ascii strings
 ********************************************************************/
 #define MAXUNI 1024
-int struni2(uint16 *p, const char *buf)
+int struni2(char *p, const char *buf)
 {
        int len = 0;
 
@@ -197,9 +197,9 @@ int struni2(uint16 *p, const char *buf)
 
        if (buf != NULL)
        {
-               for (; *buf && len < MAXUNI-2; len++, p++, buf++)
+               for (; *buf && len < MAXUNI-2; len++, p += 2, buf++)
                {
-                       *p = *buf;
+                       SSVAL(p, 0, *buf);
                }
        }
 
index 9234088404e73baa976925406dd6d9b432b7a919..dd801e59820d47a6af4304539113a7ee109a7636 100644 (file)
@@ -209,7 +209,7 @@ BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[
        generate_random_buffer((unsigned char *)data, 516, False);
        if (unicode)
        {
-               struni2( (uint16*)(&data[512 - new_pw_len]), passwd);
+               struni2( &data[512 - new_pw_len], passwd);
        }
        else
        {
index 6b3fc9415eb625b074ddad6d8840dc44e5999cb6..e1a7d3c6a595284c3b8fe907ac08cb3d582de690 100644 (file)
@@ -329,7 +329,7 @@ creates a UNISTR structure.
 void make_unistr(UNISTR *str, char *buf)
 {
        /* store the string (null-terminated copy) */
-       struni2(str->buffer, buf);
+       struni2((char *)(str->buffer), buf);
 }
 
 /*******************************************************************
@@ -372,7 +372,7 @@ void make_buffer3_str(BUFFER3 *str, char *buf, int len)
        str->buf_len     = len * 2;
 
        /* store the string (null-terminated 8 bit chars into 16 bit chars) */
-       struni2((uint16*)str->buffer, buf);
+       struni2(str->buffer, buf);
 }
 
 /*******************************************************************
@@ -573,7 +573,7 @@ void make_unistr2(UNISTR2 *str, char *buf, int len)
        str->uni_str_len = len;
 
        /* store the string (null-terminated 8 bit chars into 16 bit chars) */
-       struni2(str->buffer, buf);
+       struni2((char *)(str->buffer), buf);
 }
 
 /*******************************************************************
index b0086f402a45cb5f45f5df6ebb457b3bc3d9725c..a3d8ebb64a645ead6a17b434a5918d76c742a7e2 100644 (file)
@@ -768,8 +768,8 @@ void make_reg_r_info(REG_R_INFO *r_r,
                                uint32 level, char *os_type,
                                uint32 status)
 {
-       uint8 buf[512];
-       int len = struni2((uint16*)buf, os_type);
+       char buf[512];
+       int len = struni2(buf, os_type);
 
        r_r->ptr1 = 1;
        r_r->level = level;
index 9ce83bea831404df0ba7adcb0897accf7e90e9b7..12e94ace77d650565e07a8f4f799c9abbdb17c16 100644 (file)
@@ -707,9 +707,9 @@ void make_rpc_auth_ntlmssp_resp(RPC_AUTH_NTLMSSP_RESP *rsp,
 
        if (IS_BITS_SET_ALL(neg_flags, NTLMSSP_NEGOTIATE_UNICODE))
        {
-               struni2((uint16*)rsp->domain, domain);
-               struni2((uint16*)rsp->user  , user  );
-               struni2((uint16*)rsp->wks   , wks   );
+               struni2(rsp->domain, domain);
+               struni2(rsp->user  , user  );
+               struni2(rsp->wks   , wks   );
        }
        else
        {
index f8d882cd0c85a6717b7c4e9f5a32e78878eb7913..5908fe06b5258bb74d3792e117c958f8dccc35d9 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((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));
+               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));
        }
        else
        {
index 9791d3a38ee8f9a4c9dd16023413128db67e109e..a2e75ecc431e7e37908411aba8fa35f060e5deed 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((uint16*)(&lmdata[512-uni_pw_len]), new_pw_len);
+               pw = unistrn2(&lmdata[512-uni_pw_len], new_pw_len);
                memcpy(new_passwd, pw, new_pw_len+1);
        }
        else