Commit ff734969 authored by Tom Lane's avatar Tom Lane

Guard against overrunning CTZName buffer when TZ is bogus.

parent a0bf885f
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.101 2002/11/12 00:39:08 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.102 2002/12/12 19:16:55 tgl Exp $
* *
* NOTES * NOTES
* *
...@@ -130,14 +130,14 @@ GetCurrentAbsoluteTime(void) ...@@ -130,14 +130,14 @@ GetCurrentAbsoluteTime(void)
* XXX FreeBSD man pages indicate that this should work - thomas * XXX FreeBSD man pages indicate that this should work - thomas
* 1998-12-12 * 1998-12-12
*/ */
strcpy(CTZName, tm->tm_zone); StrNCpy(CTZName, tm->tm_zone, MAXTZLEN+1);
#elif defined(HAVE_INT_TIMEZONE) #elif defined(HAVE_INT_TIMEZONE)
tm = localtime(&now); tm = localtime(&now);
CDayLight = tm->tm_isdst; CDayLight = tm->tm_isdst;
CTimeZone = ((tm->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL); CTimeZone = ((tm->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);
strcpy(CTZName, tzname[tm->tm_isdst]); StrNCpy(CTZName, tzname[tm->tm_isdst], MAXTZLEN+1);
#else /* neither HAVE_TM_ZONE nor #else /* neither HAVE_TM_ZONE nor
* HAVE_INT_TIMEZONE */ * HAVE_INT_TIMEZONE */
CTimeZone = tb.timezone * 60; CTimeZone = tb.timezone * 60;
...@@ -212,14 +212,14 @@ GetCurrentAbsoluteTimeUsec(int *usec) ...@@ -212,14 +212,14 @@ GetCurrentAbsoluteTimeUsec(int *usec)
* XXX FreeBSD man pages indicate that this should work - thomas * XXX FreeBSD man pages indicate that this should work - thomas
* 1998-12-12 * 1998-12-12
*/ */
strcpy(CTZName, tm->tm_zone); StrNCpy(CTZName, tm->tm_zone, MAXTZLEN+1);
#elif defined(HAVE_INT_TIMEZONE) #elif defined(HAVE_INT_TIMEZONE)
tm = localtime(&now); tm = localtime(&now);
CDayLight = tm->tm_isdst; CDayLight = tm->tm_isdst;
CTimeZone = ((tm->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL); CTimeZone = ((tm->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);
strcpy(CTZName, tzname[tm->tm_isdst]); StrNCpy(CTZName, tzname[tm->tm_isdst], MAXTZLEN+1);
#else /* neither HAVE_TM_ZONE nor #else /* neither HAVE_TM_ZONE nor
* HAVE_INT_TIMEZONE */ * HAVE_INT_TIMEZONE */
CTimeZone = tb.timezone * 60; CTimeZone = tb.timezone * 60;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment