diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-01-23 21:26:20 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-01-23 21:26:20 +0000 |
commit | 4443afe59545a56fbf91ef260951fc2517cf8be6 (patch) | |
tree | 889f9cd25cd2b1cf0bc8a3501d5ac944bdb87723 | |
parent | 95ad82793d39c253a285d920fd15227b106679db (diff) | |
download | postgresql-4443afe59545a56fbf91ef260951fc2517cf8be6.tar.gz postgresql-4443afe59545a56fbf91ef260951fc2517cf8be6.zip |
Prevent integer overflow within the integer-datetimes version of
TimestampTzPlusMilliseconds. An integer argument of more than INT_MAX/1000
milliseconds (ie, about 35 minutes) would provoke a wrong result, resulting
in incorrect enforcement of statement_timestamp values larger than that.
Bug was introduced in my rewrite of 2006-06-20, which fixed some other
overflow risks, but missed this one :-( Per report from Elein.
-rw-r--r-- | src/include/utils/timestamp.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/include/utils/timestamp.h b/src/include/utils/timestamp.h index 0c6e59cc92f..5fb7529abd5 100644 --- a/src/include/utils/timestamp.h +++ b/src/include/utils/timestamp.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.64 2006/10/04 00:30:11 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.64.2.1 2008/01/23 21:26:20 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -182,7 +182,7 @@ typedef double fsec_t; #define INTERVAL_RANGE(t) (((t) >> 16) & INTERVAL_RANGE_MASK) #ifdef HAVE_INT64_TIMESTAMP -#define TimestampTzPlusMilliseconds(tz,ms) ((tz) + ((ms) * 1000)) +#define TimestampTzPlusMilliseconds(tz,ms) ((tz) + ((ms) * (int64) 1000)) #else #define TimestampTzPlusMilliseconds(tz,ms) ((tz) + ((ms) / 1000.0)) #endif |