uint32 buffer2_to_uint32(BUFFER2 *str);
char *buffer2_to_str(BUFFER2 *str);
char *buffer2_to_multistr(BUFFER2 *str);
-int struni2(char *dst, const char *src);
+int str_to_unistr16(uint16 *dst, const char *src);
+int str_to_unistr8(char *dst, const char *src);
char *unistr(char *buf);
int unistrcpy(char *dst, char *src);
int cli_set_port(struct cli_state *cli, int port);
char *cli_errstr(struct cli_state *cli);
+BOOL cli_send_trans(struct cli_state *cli, int trans,
+ char *name, int pipe_name_len,
+ int fid, int flags,
+ uint16 *setup, int lsetup, int msetup,
+ char *param, int lparam, int mparam,
+ char *data, int ldata, int mdata);
BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, int pipe_name_len,
uint16 *setup, uint32 setup_count, uint32 max_setup_count,
char *params, uint32 param_count, uint32 max_param_count,
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
+Unicode strings created are in little-endian format.
+********************************************************************/
+int str_to_unistr16(uint16 *dst, const char *src)
+{
+ size_t len = 0;
+
+ if (dst == NULL)
+ return 0;
+
+ if (src != NULL)
+ {
+ for (; *src && len < MAXUNI-2; len++, dst++, src++)
+ {
+ *dst = *src;
+ }
+ }
+
+ *dst = 0;
+
+ return len;
+}
+
/*******************************************************************
create a null-terminated unicode string from a null-terminated ascii string.
return number of unicode chars copied, excluding the null character.
Unicode strings created are in little-endian format.
********************************************************************/
-int struni2(char *dst, const char *src)
+int str_to_unistr8(char *dst, const char *src)
{
size_t len = 0;
/****************************************************************************
send a SMB trans or trans2 request
****************************************************************************/
-static BOOL cli_send_trans(struct cli_state *cli, int trans,
+BOOL cli_send_trans(struct cli_state *cli, int trans,
char *name, int pipe_name_len,
int fid, int flags,
uint16 *setup, int lsetup, int msetup,
generate_random_buffer((unsigned char *)data, 516, False);
if (unicode)
{
- struni2( &data[512 - new_pw_len], passwd);
+ str_to_unistr8( &data[512 - new_pw_len], passwd);
}
else
{
void make_unistr(UNISTR *str, char *buf)
{
/* store the string (null-terminated copy) */
- struni2((char *)(str->buffer), buf);
+ str_to_unistr16(str->buffer, buf);
}
/*******************************************************************
str->buf_len = len * 2;
/* store the string (null-terminated 8 bit chars into 16 bit chars) */
- struni2(str->buffer, buf);
+ str_to_unistr8(str->buffer, buf);
}
/*******************************************************************
str->uni_str_len = len;
/* store the string (null-terminated 8 bit chars into 16 bit chars) */
- struni2((char*)(str->buffer), buf);
+ str_to_unistr16((str->buffer), buf);
}
/*******************************************************************
uint32 status)
{
char buf[512];
- int len = struni2(buf, os_type);
+ int len = str_to_unistr8(buf, os_type);
r_r->ptr1 = 1;
r_r->level = level;
if (IS_BITS_SET_ALL(neg_flags, NTLMSSP_NEGOTIATE_UNICODE))
{
- struni2(rsp->domain, domain);
- struni2(rsp->user , user );
- struni2(rsp->wks , wks );
+ str_to_unistr8(rsp->domain, domain);
+ str_to_unistr8(rsp->user , user );
+ str_to_unistr8(rsp->wks , wks );
}
else
{