From bd0e9c7aa613edfdc3146014fb73c38df4748659 Mon Sep 17 00:00:00 2001 From: Pierre Humblet Date: Thu, 17 Jun 2004 13:34:26 +0000 Subject: 2004-06-17 Pierre Humblet * fhandler.cc (fhandler_base::open_9x): Do not check for null name. Move debug_printf to common code line. (fhandler_base::open): Ditto. Initialize upath. Remove second argument of pc.get_nt_native_path. * path.h (path_conv::get_nt_native_path): Remove second argument. * path.cc (path_conv::get_nt_native_path): Ditto. Call str2uni_cat. * security.h (str2buf2uni_cat): Delete declaration. (str2uni_cat): New declaration. * security.cc (str2buf2uni): Get length from sys_mbstowcs call. (str2buf2uni_cat): Delete function. (str2uni_cat): New function. * miscfuncs.cc (sys_mbstowcs): Add debug_printf. --- winsup/cygwin/security.cc | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'winsup/cygwin/security.cc') diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index 6ae52e9ff..c0ffadc00 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -156,23 +156,28 @@ str2buf2lsa (LSA_STRING &tgt, char *buf, const char *srcstr) memcpy (buf, srcstr, tgt.MaximumLength); } +/* The dimension of buf is assumed to be at least strlen(srcstr) + 1, + The result will be shorter if the input has multibyte chars */ void str2buf2uni (UNICODE_STRING &tgt, WCHAR *buf, const char *srcstr) { - tgt.Length = strlen (srcstr) * sizeof (WCHAR); - tgt.MaximumLength = tgt.Length + sizeof (WCHAR); tgt.Buffer = (PWCHAR) buf; - sys_mbstowcs (buf, srcstr, tgt.MaximumLength); + tgt.MaximumLength = (strlen (srcstr) + 1) * sizeof (WCHAR); + tgt.Length = sys_mbstowcs (buf, srcstr, tgt.MaximumLength / sizeof (WCHAR)) + * sizeof (WCHAR); + if (tgt.Length) + tgt.Length -= sizeof (WCHAR); } void -str2buf2uni_cat (UNICODE_STRING &tgt, const char *srcstr) +str2uni_cat (UNICODE_STRING &tgt, const char *srcstr) { - DWORD len = strlen (srcstr) * sizeof (WCHAR); - sys_mbstowcs (tgt.Buffer + tgt.Length / sizeof (WCHAR), srcstr, - len + tgt.MaximumLength); - tgt.Length += len; - tgt.MaximumLength += len; + int len = sys_mbstowcs (tgt.Buffer + tgt.Length / sizeof (WCHAR), srcstr, + (tgt.MaximumLength - tgt.Length) / sizeof (WCHAR)); + if (len) + tgt.Length += (len - 1) * sizeof (WCHAR); + else + tgt.Length = tgt.MaximumLength = 0; } #if 0 /* unused */ -- cgit v1.2.3