/*The following definitions come from lib/util_unistr.c */
-int dos_PutUniCode(char *dst,const char *src, ssize_t len);
+int dos_PutUniCode(char *dst,const char *src, ssize_t len, BOOL null_terminate);
void ascii_to_unistr(uint16 *dest, const char *src, int maxlen);
void unistr_to_ascii(char *dest, const uint16 *src, int len);
char *skip_unicode_string(char *buf,int n);
the current DOS codepage. len is the length in bytes of the
string pointed to by dst.
- the return value is the length of the string *without* the trailing
- two bytes of zero
+ if null_terminate is True then null terminate the packet (adds 2 bytes)
+
+ the return value is the length consumed by the string, including the
+ null termination if applied
********************************************************************/
-int dos_PutUniCode(char *dst,const char *src, ssize_t len)
+int dos_PutUniCode(char *dst,const char *src, ssize_t len, BOOL null_terminate)
{
int ret = 0;
while (*src && (len > 2)) {
else
src++;
}
- SSVAL(dst,ret,0);
+ if (null_terminate) {
+ SSVAL(dst,ret,0);
+ ret += 2;
+ }
return(ret);
}
mailslot_name = bufp;
bufp += (strlen(bufp) + 1);
bufp = align2(bufp, buffer);
- dos_PutUniCode(bufp, srcname, sizeof(buffer) - (bufp - buffer) - 1);
- bufp = skip_unicode_string(bufp, 1);
+ bufp += dos_PutUniCode(bufp, srcname, sizeof(buffer) - (bufp - buffer) - 1, True);
SIVAL(bufp,0,1);
SSVAL(bufp,4,0xFFFF);
SSVAL(bufp,6,0xFFFF);
{
q = align2(q, buf);
- dos_PutUniCode(q, my_name, sizeof(pstring)); /* PDC name */
- q = skip_unicode_string(q, 1);
-
- dos_PutUniCode(q, global_myworkgroup,sizeof(pstring)); /* Domain name*/
- q = skip_unicode_string(q, 1);
+ q += dos_PutUniCode(q, my_name, sizeof(pstring), True); /* PDC name */
+ q += dos_PutUniCode(q, global_myworkgroup,sizeof(pstring), True); /* Domain name*/
SIVAL(q, 0, ntversion);
SSVAL(q, 4, lmnttoken);
}
q += 2;
- dos_PutUniCode(q, reply_name,sizeof(pstring));
- q = skip_unicode_string(q, 1);
+ q += dos_PutUniCode(q, reply_name,sizeof(pstring), True);
unistrcpy(q, uniuser);
q = skip_unicode_string(q, 1); /* User name (workstation trust account) */
- dos_PutUniCode(q, lp_workgroup(),sizeof(pstring));
- q = skip_unicode_string(q, 1); /* Domain name. */
+ q += dos_PutUniCode(q, lp_workgroup(),sizeof(pstring), True);
SIVAL(q, 0, ntversion);
q += 4;
#endif /* Old code. */
SIVAL(pdata,4,128); /* Max filename component length */
- fstype_len = dos_PutUniCode(pdata+12,unix_to_dos(fstype,False),sizeof(pstring)/2);
+ fstype_len = dos_PutUniCode(pdata+12,unix_to_dos(fstype,False),sizeof(pstring), False);
SIVAL(pdata,8,fstype_len);
data_len = 12 + fstype_len;
SSVAL(outbuf,smb_flg2,SVAL(outbuf,smb_flg2)|FLAGS2_UNICODE_STRINGS);
} else {
data_len = 18 + 2*strlen(vname);
SIVAL(pdata,12,strlen(vname)*2);
- dos_PutUniCode(pdata+18,unix_to_dos(vname,False),sizeof(pstring)/2);
+ dos_PutUniCode(pdata+18,unix_to_dos(vname,False),sizeof(pstring), False);
}
DEBUG(5,("call_trans2qfsinfo : SMB_QUERY_FS_VOLUME_INFO namelen = %d, vol = %s\n",
}
strupper(short_name);
l = strlen(short_name);
- dos_PutUniCode(pdata + 4, unix_to_dos(short_name,False),sizeof(pstring)*2);
+ dos_PutUniCode(pdata + 4, unix_to_dos(short_name,False),sizeof(pstring), False);
data_size = 4 + (2*l);
SIVAL(pdata,0,2*l);
}
if(strequal(".", fname) && (global_client_caps & CAP_UNICODE)) {
l = l*2;
SSVAL(outbuf,smb_flg2,SVAL(outbuf,smb_flg2)|FLAGS2_UNICODE_STRINGS);
- dos_PutUniCode(pdata + 4, unix_to_dos("\\",False),sizeof(pstring)*2);
+ dos_PutUniCode(pdata + 4, unix_to_dos("\\",False),sizeof(pstring), False);
} else {
pstrcpy(pdata+4,fname);
}