aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/security.cc
diff options
context:
space:
mode:
authorPierre Humblet <phumblet@phumblet.no-ip.org>2004-06-17 13:34:26 +0000
committerPierre Humblet <phumblet@phumblet.no-ip.org>2004-06-17 13:34:26 +0000
commitbd0e9c7aa613edfdc3146014fb73c38df4748659 (patch)
tree31f22d9165d03ec109ea29e19480599e81b8abb5 /winsup/cygwin/security.cc
parent9f35b464563d391929da0326ea37c15e6099cdce (diff)
downloadnewlib-bd0e9c7aa613edfdc3146014fb73c38df4748659.zip
newlib-bd0e9c7aa613edfdc3146014fb73c38df4748659.tar.gz
newlib-bd0e9c7aa613edfdc3146014fb73c38df4748659.tar.bz2
2004-06-17 Pierre Humblet <pierre.humblet@ieee.org>
* 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.
Diffstat (limited to 'winsup/cygwin/security.cc')
-rw-r--r--winsup/cygwin/security.cc23
1 files changed, 14 insertions, 9 deletions
diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc
index 6ae52e9..c0ffadc 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 */