1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-27 14:04:05 +03:00

UNICODE byte ordering issue: typecast to uint16* replaced with SSVAL()

This commit is contained in:
Luke Leighton -
parent 9ab81caa06
commit 9084b7e33d
8 changed files with 21 additions and 21 deletions

View 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);

View 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);
}
}

View 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
{

View 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);
}
/*******************************************************************

View 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;

View 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
{

View 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
{

View 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