Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2008-07-14 23:58:16 +0400
committerCorinna Vinschen <corinna@vinschen.de>2008-07-14 23:58:16 +0400
commitbf216dcad6ff26bc9c160402da639fdc89614fb4 (patch)
tree72982fc55a8dfc7d988eca8f35d169addab11a6c /winsup/cygwin/miscfuncs.cc
parent88d1b6df9404ee846a455fffb7bef7623010b1aa (diff)
* miscfuncs.cc (cygwin_strncasecmp): Fix bug which results in
prematurely truncated strings. Simplify target length argument to sys_mbstowcs.
Diffstat (limited to 'winsup/cygwin/miscfuncs.cc')
-rw-r--r--winsup/cygwin/miscfuncs.cc10
1 files changed, 4 insertions, 6 deletions
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index aff357d1a..845575edf 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -130,16 +130,14 @@ cygwin_strncasecmp (const char *cs, const char *ct, size_t n)
while (cs[ls] && ls < n)
++ls;
- len = ls * sizeof (WCHAR);
+ len = (ls + 1) * sizeof (WCHAR);
RtlInitEmptyUnicodeString (&us, (PWCHAR) alloca (len), len);
- us.Length = sys_mbstowcs (us.Buffer, us.MaximumLength / sizeof (WCHAR),
- cs, ls) * sizeof (WCHAR);
+ us.Length = sys_mbstowcs (us.Buffer, ls + 1, cs, ls) * sizeof (WCHAR);
while (ct[lt] && lt < n)
++lt;
- len = lt * sizeof (WCHAR);
+ len = (lt + 1) * sizeof (WCHAR);
RtlInitEmptyUnicodeString (&ut, (PWCHAR) alloca (len), len);
- ut.Length = sys_mbstowcs (ut.Buffer, ut.MaximumLength / sizeof (WCHAR),
- ct, lt) * sizeof (WCHAR);
+ ut.Length = sys_mbstowcs (ut.Buffer, lt + 1, ct, lt) * sizeof (WCHAR);
return RtlCompareUnicodeString (&us, &ut, TRUE);
}