From 23b8a0ce61c0fac72c9b40acb875bb0ab0a5b915 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 29 Jan 2003 01:08:42 +0000 Subject: Repair array subscript overrun identified by Yichen Xie. Reduce the value of MAX_TIME_PRECISION in floating-point-timestamp-storage case from 13 to 10, which is as much as time_out is actually willing to print. (The alternative of increasing the number of digits we are willing to print looks risky; we might find ourselves printing roundoff garbage.) --- src/backend/utils/adt/date.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/backend/utils/adt/date.c') diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index 11a58b41746..90f41ad817d 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.76 2003/01/22 20:44:20 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.77 2003/01/29 01:08:42 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -619,7 +619,7 @@ static void AdjustTimeForTypmod(TimeADT *time, int32 typmod) { #ifdef HAVE_INT64_TIMESTAMP - static const int64 TimeScales[MAX_TIMESTAMP_PRECISION + 1] = { + static const int64 TimeScales[MAX_TIME_PRECISION + 1] = { INT64CONST(1000000), INT64CONST(100000), INT64CONST(10000), @@ -629,7 +629,7 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod) INT64CONST(1) }; - static const int64 TimeOffsets[MAX_TIMESTAMP_PRECISION + 1] = { + static const int64 TimeOffsets[MAX_TIME_PRECISION + 1] = { INT64CONST(500000), INT64CONST(50000), INT64CONST(5000), @@ -640,14 +640,19 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod) }; #else - static const double TimeScales[MAX_TIMESTAMP_PRECISION + 1] = { + /* note MAX_TIME_PRECISION differs in this case */ + static const double TimeScales[MAX_TIME_PRECISION + 1] = { 1, 10, 100, 1000, 10000, 100000, - 1000000 + 1000000, + 10000000, + 100000000, + 1000000000, + 10000000000 }; #endif -- cgit v1.2.3