aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2016-05-25 12:13:03 +0200
committerCorinna Vinschen <corinna@vinschen.de>2016-05-25 12:13:03 +0200
commit030d86d04dbd6ae878ff894256c5a465890d5970 (patch)
tree1eee89562f21b687e762b234b857c7a75101ba99
parent3b66731698a72e5912f867e4aa8c170332c510fb (diff)
downloadnewlib-030d86d04dbd6ae878ff894256c5a465890d5970.zip
newlib-030d86d04dbd6ae878ff894256c5a465890d5970.tar.gz
newlib-030d86d04dbd6ae878ff894256c5a465890d5970.tar.bz2
TZ: Replace unreliable isupper calls on wchars
In case the TZ variable is empty, Cygwin fetches timezone info from Windows. Extracting the timezone short name uses isupper on wide chars. Replace with explicit check for A <= character <= Z to be independent of undefined behaviour. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r--winsup/cygwin/localtime.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/winsup/cygwin/localtime.cc b/winsup/cygwin/localtime.cc
index d57a020..2d10508 100644
--- a/winsup/cygwin/localtime.cc
+++ b/winsup/cygwin/localtime.cc
@@ -1543,7 +1543,8 @@ tzsetwall (void)
GetTimeZoneInformation(&tz);
dst = cp = buf;
for (src = tz.StandardName; *src; src++)
- if (isupper(*src)) *dst++ = *src;
+ if (*src >= L'A' && *src <= L'Z')
+ *dst++ = *src;
if ((dst - cp) < 3)
{
/* In non-english Windows, converted tz.StandardName
@@ -1561,7 +1562,8 @@ tzsetwall (void)
cp = strchr(cp, 0);
dst = cp;
for (src = tz.DaylightName; *src; src++)
- if (isupper(*src)) *dst++ = *src;
+ if (*src >= L'A' && *src <= L'Z')
+ *dst++ = *src;
if ((dst - cp) < 3)
{
/* In non-english Windows, converted tz.DaylightName