*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.76 1999/07/17 20:17:55 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.77 1999/12/09 05:02:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if ((*tzn != NULL) && (tm->tm_isdst >= 0))
{
strcpy((str + 27), " ");
- strcpy((str + 28), *tzn);
+ strncpy((str + 28), *tzn, MAXTZLEN);
}
}
else
if ((*tzn != NULL) && (tm->tm_isdst >= 0))
{
strcpy((str + 24), " ");
- strcpy((str + 25), *tzn);
+ strncpy((str + 25), *tzn, MAXTZLEN);
}
}
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: nabstime.c,v 1.61 1999/07/17 20:17:57 momjian Exp $
+ * $Id: nabstime.c,v 1.62 1999/12/09 05:02:24 momjian Exp $
*
*/
#include <ctype.h>
*tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */
/* XXX FreeBSD man pages indicate that this should work - tgl 97/04/23 */
if (tzn != NULL)
- strcpy(tzn, tm->tm_zone);
+ {
+ /* Copy no more than MAXTZLEN bytes of timezone to tzn, in case it
+ contains an error message, which doesn't fit in the buffer */
+ strncpy(tzn, tm->tm_zone, MAXTZLEN);
+ if (strlen(tm->tm_zone) > MAXTZLEN)
+ {
+ tzn[MAXTZLEN] = '\0';
+ elog(NOTICE, "Invalid timezone \'%s\'", tm->tm_zone);
+ }
+ }
#elif defined(HAVE_INT_TIMEZONE)
if (tzp != NULL)
#ifdef __CYGWIN__
*tzp = (tm->tm_isdst ? (timezone - 3600) : timezone);
#endif
if (tzn != NULL)
- strcpy(tzn, tzname[tm->tm_isdst]);
+ {
+ /* Copy no more than MAXTZLEN bytes of timezone to tzn, in case it
+ contains an error message, which doesn't fit in the buffer */
+ strncpy(tzn, tzname[tm->tm_isdst], MAXTZLEN);
+ if (strlen(tzname[tm->tm_isdst]) > MAXTZLEN)
+ {
+ tzn[MAXTZLEN] = '\0';
+ elog(NOTICE, "Invalid timezone \'%s\'", tzname[tm->tm_isdst]);
+ }
+ }
#else
#error POSIX time support is broken
#endif