aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/time
diff options
context:
space:
mode:
authorYaakov Selkowitz <yselkowi@redhat.com>2015-03-25 16:26:07 -0500
committerCorinna Vinschen <corinna@vinschen.de>2015-04-23 21:57:08 +0200
commit95a4fc87264e5fdeb5452d63d3b2df217a2f19b2 (patch)
tree4eb4e0db5158df247a7ddc0b2093f964274b74fa /newlib/libc/time
parent75d5f68aabf62c42884ff935f888b12bbcd00001 (diff)
downloadnewlib-95a4fc87264e5fdeb5452d63d3b2df217a2f19b2.zip
newlib-95a4fc87264e5fdeb5452d63d3b2df217a2f19b2.tar.gz
newlib-95a4fc87264e5fdeb5452d63d3b2df217a2f19b2.tar.bz2
strftime: use tzname if TM_ZONE is NULL
This avoids a strlen(NULL) crash a few lines later. * libc/time/strftime.c (strftime) <%Z>: Initialize tznam to NULL. Use _tzname as fallback if TM_ZONE is NULL.
Diffstat (limited to 'newlib/libc/time')
-rw-r--r--newlib/libc/time/strftime.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/newlib/libc/time/strftime.c b/newlib/libc/time/strftime.c
index 7db3383..ee604c2 100644
--- a/newlib/libc/time/strftime.c
+++ b/newlib/libc/time/strftime.c
@@ -1311,7 +1311,7 @@ recurse:
if (tim_p->tm_isdst >= 0)
{
size_t size;
- const char *tznam;
+ const char *tznam = NULL;
TZ_LOCK;
#if defined (__CYGWIN__)
@@ -1320,9 +1320,9 @@ recurse:
tznam = __cygwin_gettzname (tim_p);
#elif defined (__TM_ZONE)
tznam = tim_p->__TM_ZONE;
-#else
- tznam = _tzname[tim_p->tm_isdst > 0];
#endif
+ if (!tznam)
+ tznam = _tzname[tim_p->tm_isdst > 0];
/* Note that in case of wcsftime this loop only works for
timezone abbreviations using the portable codeset (aka ASCII).
This seems to be the case, but if that ever changes, this